/* ==========================================================================
   Diwaller — SaaS-clean re-skin
   --------------------------------------------------------------------------
   Refined SaaS B2B aesthetic — off-white, teal accent, Bricolage display +
   Geist UI + JetBrains Mono. Distinctive but professional, never bland.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1 · RESET
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }
button { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }
[x-cloak] { display: none !important; }

/* --------------------------------------------------------------------------
   2 · TOKENS
   -------------------------------------------------------------------------- */

:root {
  /* Background system — warm off-white, never sterile pure-white */
  --bg:           #FAFAF7;
  --surface:      #FFFFFF;
  --surface-2:   #F4F4ED;
  --surface-3:   #ECECE3;

  /* Borders */
  --border:        rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --border-soft:   rgba(15, 23, 42, 0.05);

  /* Ink — deep navy not pure black */
  --ink:    #0E1726;
  --ink-2:  #475569;
  --ink-3:  #94A3B8;
  --ink-4:  #CBD5E1;

  /* Accent — sophisticated teal, slightly desaturated */
  --accent:        #0EA5A0;
  --accent-hover:  #0D8A86;
  --accent-pressed:#096863;
  --accent-ink:    #064E4B;
  --accent-soft:   #ECFDF5;
  --accent-soft-2: #D1FAE5;

  /* Status hues — calibrated for pills */
  --positive:        #059669;
  --positive-soft:   #D1FAE5;
  --neutral:         #4F46E5;
  --neutral-soft:    #E0E7FF;
  --warn:            #B45309;
  --warn-soft:       #FEF3C7;
  --danger:          #DC2626;
  --danger-soft:     #FEE2E2;
  --hold:            #C2410C;
  --hold-soft:       #FFEDD5;
  --info:            #0891B2;
  --info-soft:       #CFFAFE;

  /* Tone hues — Bodyguard-style moderation palette (6 tones) */
  --tone-positive:    #22c55e;
  --tone-criticism:   #a855f7;
  --tone-neutral:     #3b82f6;
  --tone-hateful:     #f59e0b;
  --tone-hate-speech: #f97316;
  --tone-undesirable: #ef4444;
  /* Action hues — moderation outcomes */
  --action-kept:           #22c55e;
  --action-auto-removed:   #f97316;
  --action-manual-removed: #b91c1c;

  /* Platform hues — picked far apart on the hue wheel so the four series
     on the Dashboard charts (YT/FB/IG/TT) stay distinguishable. Used by
     source badges *and* charts for visual consistency across Diwaller. */
  --platform-youtube:   #FF0000;  /* red       (0°)   */
  --platform-tiktok:    #00C896;  /* teal-green (160°)*/
  --platform-facebook:  #1877F2;  /* blue      (217°) */
  --platform-instagram: #8134AF;  /* purple    (282°) */
  /* Contrast text colors for badges that need dark ink on light bg */
  --platform-tiktok-ink:    #06342B;
  --platform-instagram-ink: #FFFFFF;

  /* Decision colors mapped to local taxonomy */
  --hue-keep:    var(--positive);
  --hue-keep-soft: var(--positive-soft);
  --hue-delete:  var(--danger);
  --hue-delete-soft: var(--danger-soft);
  --hue-hold:    var(--hold);
  --hue-hold-soft: var(--hold-soft);
  --hue-reply:   var(--accent);
  --hue-reply-soft: var(--accent-soft);
  --hue-pending: var(--ink-3);
  --hue-pending-soft: var(--surface-3);
  --hue-error:   var(--danger);

  /* Typography — Bricolage display / Geist UI / JetBrains mono */
  --font-display: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --font-ui: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;

  /* Type scale */
  --fs-xs:   0.75rem;
  --fs-sm:   0.875rem;
  --fs-base: 0.9375rem;
  --fs-md:   1rem;
  --fs-lg:   1.125rem;
  --fs-xl:   1.375rem;
  --fs-2xl:  1.75rem;
  --fs-3xl:  2.5rem;

  /* Spacing — 4-base */
  --s-1:  0.25rem;
  --s-2:  0.5rem;
  --s-3:  0.75rem;
  --s-4:  1rem;
  --s-5:  1.25rem;
  --s-6:  1.5rem;
  --s-7:  1.75rem;
  --s-8:  2rem;
  --s-10: 2.5rem;
  --s-12: 3rem;

  /* Radii */
  --r-sm:  4px;
  --r-md:  6px;
  --r-lg:  10px;
  --r-xl:  14px;
  --r-2xl: 20px;
  --r-full: 999px;

  /* Shadows — long, soft, never the generic Material card */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 6px -1px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 8px 16px -6px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 18px 32px -12px rgba(15, 23, 42, 0.12), 0 4px 8px -4px rgba(15, 23, 42, 0.06);
  --shadow-focus: 0 0 0 3px rgba(14, 165, 160, 0.18);

  /* Layout dimensions */
  --sidebar-w:      64px;
  --topbar-h:       60px;
  --content-max:    1320px;
  --content-pad:    var(--s-8);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --t-fast: 120ms;
  --t-med:  180ms;
  --t-slow: 280ms;
}

/* --------------------------------------------------------------------------
   3 · BASE
   -------------------------------------------------------------------------- */

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.55;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
}

/* Subtle paper grain — distinctive without being noisy */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.06  0 0 0 0 0.09  0 0 0 0 0.15  0 0 0 0.025 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* --------------------------------------------------------------------------
   4 · TYPOGRAPHY
   -------------------------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.018em;
  margin: 0;
  color: var(--ink);
}

h1 { font-size: var(--fs-2xl); line-height: 1.15; }
h2 { font-size: var(--fs-xl); line-height: 1.2; }
h3 { font-size: var(--fs-lg); line-height: 1.3; }
h4 { font-size: var(--fs-md); line-height: 1.35; font-weight: 500; }

p { margin: 0; }

.mono, code, pre, .num { font-family: var(--font-mono); font-feature-settings: 'tnum'; }
.faint { color: var(--ink-3); }
.italic { font-style: italic; }

/* --------------------------------------------------------------------------
   5 · LAYOUT
   -------------------------------------------------------------------------- */

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100dvh;
}

/* ===== Sidebar ===== */
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--s-4) 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 10;
}

.sidebar__brand {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-lg);
  margin-bottom: var(--s-6);
  background: linear-gradient(135deg, var(--accent) 0%, #14B8A6 60%, #0EA5A0 100%);
  color: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast) var(--ease);
}
.sidebar__brand:hover { transform: rotate(-4deg) scale(1.05); }
.sidebar__brand svg { width: 22px; height: 22px; }

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  flex: 1;
}

.sidebar__item {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-lg);
  color: var(--ink-3);
  transition: all var(--t-fast) var(--ease);
}
.sidebar__item:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.sidebar__item.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.sidebar__item.is-active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  background: var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.sidebar__item svg { width: 20px; height: 20px; }

.sidebar__bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
}

.sidebar__avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--ink);
  color: var(--surface);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.5px;
  margin-top: var(--s-2);
}

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 9;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--content-pad);
  background: rgba(250, 250, 247, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--fs-sm);
}
.breadcrumb__org {
  font-weight: 600;
  color: var(--ink);
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}
.breadcrumb__sep {
  color: var(--ink-4);
  font-size: var(--fs-base);
}
.breadcrumb__crumb {
  color: var(--ink-2);
}
.breadcrumb__crumb.is-active {
  color: var(--ink);
  font-weight: 500;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.topbar__pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 36px;
  padding: 0 var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  transition: border-color var(--t-fast);
}
.topbar__pill:hover { border-color: var(--border-strong); }
.topbar__pill svg { width: 14px; height: 14px; opacity: 0.7; }

.topbar__icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--r-lg);
  color: var(--ink-2);
  position: relative;
  transition: background-color var(--t-fast);
}
.topbar__icon-btn:hover { background: var(--surface-2); }
.topbar__icon-btn svg { width: 18px; height: 18px; }
.topbar__icon-btn .dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  background: var(--accent);
  border: 1.5px solid var(--surface);
}

/* ===== Main ===== */
.main {
  min-height: calc(100dvh - var(--topbar-h));
}

.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-7) var(--content-pad) var(--s-12);
}

/* --------------------------------------------------------------------------
   6 · COMPONENTS — FILTER BAR
   -------------------------------------------------------------------------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-7);
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 36px;
  padding: 0 var(--s-4);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-lg);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--t-fast);
}
.filter-pill:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--ink);
}
.filter-pill:active {
  background: var(--surface-3);
  transform: translateY(0.5px);
}
.filter-pill:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
.filter-pill svg { width: 14px; height: 14px; opacity: 0.7; }
.filter-pill__caret { width: 12px; height: 12px; opacity: 0.5; }
.filter-pill.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* --------------------------------------------------------------------------
   7 · COMPONENTS — SECTION
   -------------------------------------------------------------------------- */

.section {
  margin-bottom: var(--s-10);
}

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--s-5);
  gap: var(--s-4);
}

.section__title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--ink);
  margin: 0;
}

.section__link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--accent);
  font-weight: 500;
  transition: color var(--t-fast);
}
.section__link:hover { color: var(--accent-hover); }
.section__link svg { width: 14px; height: 14px; }

/* --------------------------------------------------------------------------
   8 · COMPONENTS — CARD
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s-6);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t-med), border-color var(--t-med);
}
.card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-strong);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
}
.card__title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.card__menu-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  color: var(--ink-3);
  transition: all var(--t-fast);
}
.card__menu-btn:hover { background: var(--surface-2); color: var(--ink); }
.card__menu-btn svg { width: 16px; height: 16px; }

/* --------------------------------------------------------------------------
   9 · COMPONENTS — KPI GRID
   -------------------------------------------------------------------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-5);
}

@media (max-width: 980px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s-6);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t-med), border-color var(--t-med);
}
.kpi:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-strong);
}

.kpi__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-3);
}

.kpi__label {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  font-weight: 500;
}

.kpi__expand {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--ink-3);
  opacity: 0;
  transition: opacity var(--t-fast);
}
.kpi:hover .kpi__expand { opacity: 1; }
.kpi__expand svg { width: 14px; height: 14px; }

.kpi__value {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 600;
  font-feature-settings: 'tnum';
  letter-spacing: -0.025em;
  color: var(--ink);
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
}

.kpi__pct {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-2);
  font-family: var(--font-ui);
  letter-spacing: 0;
}

.kpi__delta {
  margin-top: var(--s-3);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--ink-3);
}
.kpi__delta-num {
  font-family: var(--font-mono);
  font-weight: 500;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

/* --------------------------------------------------------------------------
   10 · COMPONENTS — TWO-COLUMN ROW
   -------------------------------------------------------------------------- */

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
}
@media (max-width: 900px) { .row-2 { grid-template-columns: 1fr; } }

.row-3-2 {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: var(--s-5);
}
@media (max-width: 900px) { .row-3-2 { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------------
   11 · COMPONENTS — DISTRIBUTION LIST
   -------------------------------------------------------------------------- */

.dist-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3) var(--s-7);
}
@media (max-width: 540px) { .dist-list { grid-template-columns: 1fr; } }

.dist-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.dist-row__icon {
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.dist-row__icon svg { width: 14px; height: 14px; }
.dist-row__label {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  flex: 1;
}
.dist-row__value {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
}
.dist-row[data-tone='positive'] .dist-row__icon { background: var(--positive-soft); color: var(--positive); }
.dist-row[data-tone='neutral']  .dist-row__icon { background: var(--neutral-soft); color: var(--neutral); }
.dist-row[data-tone='warn']     .dist-row__icon { background: var(--warn-soft); color: var(--warn); }
.dist-row[data-tone='danger']   .dist-row__icon { background: var(--danger-soft); color: var(--danger); }
.dist-row[data-tone='hold']     .dist-row__icon { background: var(--hold-soft); color: var(--hold); }
.dist-row[data-tone='reply']    .dist-row__icon { background: var(--accent-soft); color: var(--accent); }

/* --------------------------------------------------------------------------
   12 · COMPONENTS — FEED (live activity)
   -------------------------------------------------------------------------- */

.feed-card { display: flex; flex-direction: column; max-height: 540px; }

.feed-status {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-xs);
  color: var(--ink-3);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.feed-status__dot {
  width: 8px; height: 8px;
  border-radius: var(--r-full);
  background: var(--ink-3);
}
.feed-status.is-on .feed-status__dot {
  background: var(--positive);
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.15);
  animation: pulse 1.6s var(--ease) infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
}

.feed-list {
  flex: 1;
  overflow-y: auto;
  padding-top: var(--s-3);
  margin-right: calc(var(--s-6) * -1);
  padding-right: var(--s-6);
}
.feed-list::-webkit-scrollbar { width: 6px; }
.feed-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-full); }
.feed-list::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

.feed-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-2) var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border-soft);
}
.feed-item:last-child { border-bottom: 0; }

.feed-item__time {
  grid-column: 1;
  grid-row: 1;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-3);
  align-self: center;
}
.feed-item__author {
  grid-column: 2;
  grid-row: 1;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
  align-self: center;
}
.feed-item__tag {
  grid-column: 3;
  grid-row: 1;
}
.feed-item__body {
  grid-column: 2 / -1;
  grid-row: 2;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-empty {
  text-align: center;
  padding: var(--s-12) var(--s-4);
  color: var(--ink-3);
  font-size: var(--fs-sm);
}

/* --------------------------------------------------------------------------
   13 · COMPONENTS — TAG / STATUS PILL
   -------------------------------------------------------------------------- */

.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 var(--s-3);
  border-radius: var(--r-md);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
  font-family: var(--font-ui);
}

.tag--keep    { color: var(--positive); background: var(--positive-soft); }
.tag--delete  { color: var(--danger);   background: var(--danger-soft); }
.tag--hold    { color: var(--hold);     background: var(--hold-soft); }
.tag--reply   { color: var(--accent);   background: var(--accent-soft); }
.tag--pending { color: var(--ink-2);    background: var(--surface-3); }
.tag--error   { color: var(--danger);   background: var(--danger-soft); }
.tag--neutral { color: var(--neutral);  background: var(--neutral-soft); }
.tag--high    { color: var(--danger);   background: var(--danger-soft); }
.tag--low     { color: var(--positive); background: var(--positive-soft); }
.tag--none    { color: var(--ink-3);    background: var(--surface-3); }

/* --------------------------------------------------------------------------
   14 · COMPONENTS — DATA TABLE
   -------------------------------------------------------------------------- */

.dt {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}

.dt thead th {
  padding: var(--s-3) var(--s-4);
  text-align: left;
  font-weight: 500;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.dt tbody td {
  padding: var(--s-4) var(--s-4);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
  color: var(--ink);
}

.dt tbody tr { transition: background-color var(--t-fast); }
.dt tbody tr:hover { background: var(--surface-2); }
.dt tbody tr:last-child td { border-bottom: 0; }

.dt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.dt__cell-mono { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-2); }
.dt__cell-num  { font-family: var(--font-mono); font-feature-settings: 'tnum'; text-align: right; }
.dt__cell-text { color: var(--ink); }
.dt__cell-text-meta {
  display: block;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-top: 2px;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dt__cell-actions {
  text-align: right;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   15 · COMPONENTS — TABLE TOOLBAR / PAGINATION
   -------------------------------------------------------------------------- */

.dt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.dt-toolbar__count {
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.dt-toolbar__count strong { color: var(--ink); font-weight: 600; }

.dt-pagination {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.dt-pagination__group {
  display: flex;
  gap: var(--s-1);
  margin-left: auto;
}

/* --------------------------------------------------------------------------
   16 · COMPONENTS — BUTTONS
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 36px;
  padding: 0 var(--s-4);
  border-radius: var(--r-lg);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--ink);
  transition: all var(--t-fast);
  white-space: nowrap;
}
.btn:hover  { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-xs);
}
.btn--primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-sm); }
.btn--primary:active { background: var(--accent-pressed); }

.btn--ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--border);
}
.btn--ghost:hover { color: var(--ink); border-color: var(--border-strong); background: var(--surface); }

.btn--danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
}
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn--sm { height: 30px; padding: 0 var(--s-3); font-size: var(--fs-xs); border-radius: var(--r-md); }

.iconbtn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  color: var(--ink-3);
  transition: all var(--t-fast);
  border: 1px solid transparent;
  background: transparent;
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn svg { width: 14px; height: 14px; }
.iconbtn--danger:hover { background: var(--danger-soft); color: var(--danger); }

.linkbtn {
  font-size: var(--fs-sm);
  color: var(--accent);
  cursor: pointer;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  transition: background-color var(--t-fast);
}
.linkbtn:hover { background: var(--accent-soft); }
.linkbtn--danger { color: var(--danger); }
.linkbtn--danger:hover { background: var(--danger-soft); }

/* --------------------------------------------------------------------------
   17 · COMPONENTS — FORMS
   -------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.field__label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

.field__hint {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  line-height: 1.5;
}

.field__value {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--ink-2);
  padding: 1px 6px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-sm);
  color: var(--ink);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.input--narrow { width: 5rem; }

.range {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  outline: none;
}
.range::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: var(--r-full);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-fast);
}
.range::-webkit-slider-thumb:hover { transform: scale(1.15); }
.range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: var(--r-full);
  border: 0;
  cursor: pointer;
}
.range--hold::-webkit-slider-thumb { background: var(--hold); }
.range--hold::-moz-range-thumb { background: var(--hold); }

.checkbox {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.checkbox input {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--t-fast);
}
.checkbox input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox input:checked::after {
  content: '';
  width: 4px;
  height: 8px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg) translate(-1px, -1px);
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  cursor: pointer;
  padding: var(--s-3) 0;
}
.toggle-row__label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
}
.toggle {
  display: inline-block;
  flex-shrink: 0;
  margin-top: 2px;
}
.toggle input {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 18px;
  background: var(--ink-4);
  border-radius: var(--r-full);
  cursor: pointer;
  position: relative;
  transition: background-color var(--t-fast);
}
.toggle input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: var(--r-full);
  transition: transform var(--t-fast);
  box-shadow: var(--shadow-xs);
}
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(14px); }

/* --------------------------------------------------------------------------
   18 · COMPONENTS — BANNERS & ALERTS
   -------------------------------------------------------------------------- */

.banner {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
}
.banner--ok { background: var(--positive-soft); color: var(--positive); }
.banner--err { background: var(--danger-soft); color: var(--danger); }
.banner--info { background: var(--accent-soft); color: var(--accent-ink); }

.notice {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--r-lg);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  align-items: flex-start;
}
.notice strong { color: var(--ink); display: block; margin-bottom: 2px; font-weight: 600; }
.notice__icon {
  width: 32px; height: 32px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
}
.notice__icon svg { width: 16px; height: 16px; }
.notice a { color: var(--accent); font-weight: 500; }

/* --------------------------------------------------------------------------
   19 · COMPONENTS — MODAL
   -------------------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: var(--s-4);
  animation: fade-in var(--t-med) var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal__panel {
  background: var(--surface);
  border-radius: var(--r-2xl);
  padding: var(--s-7);
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: scale-in var(--t-med) var(--ease);
}
@keyframes scale-in { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal__title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  margin: 0 0 var(--s-2) 0;
}

.modal__quote {
  margin: 0 0 var(--s-4) 0;
  padding: var(--s-3) var(--s-4);
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-style: italic;
  color: var(--ink-2);
  line-height: 1.5;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  margin-top: var(--s-5);
}

/* --------------------------------------------------------------------------
   20 · COMPONENTS — SETTINGS LAYOUT
   -------------------------------------------------------------------------- */

.settings-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--s-7);
  align-items: flex-start;
}
@media (max-width: 800px) { .settings-shell { grid-template-columns: 1fr; } }

.settings-nav {
  position: sticky;
  top: calc(var(--topbar-h) + var(--s-5));
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.settings-nav__item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--t-fast);
  text-align: left;
}
.settings-nav__item:hover { background: var(--surface-2); color: var(--ink); }
.settings-nav__item.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 500;
}
.settings-nav__item svg { width: 16px; height: 16px; flex-shrink: 0; }

.settings-content { min-width: 0; }

.settings-block { margin-bottom: var(--s-10); }

.settings-block__head { margin-bottom: var(--s-4); }
.settings-block__title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 600;
  margin: 0 0 var(--s-2);
  color: var(--ink);
  letter-spacing: -0.012em;
}
.settings-block__desc {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  line-height: 1.5;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-5);
}
@media (max-width: 600px) { .settings-grid { grid-template-columns: 1fr; } }

.settings-action-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-lg);
  position: sticky;
  bottom: var(--s-4);
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------------------
   21 · COMPONENTS — TOOLTIP (info pin)
   -------------------------------------------------------------------------- */

.info-anchor { position: relative; display: inline-block; margin-left: var(--s-2); }

.info-pin {
  width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 600;
  display: inline-grid;
  place-items: center;
  cursor: help;
  transition: all var(--t-fast);
  vertical-align: middle;
}
.info-pin:hover { background: var(--accent-soft); color: var(--accent); }

.info-tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.96);
  background: var(--ink);
  color: var(--surface);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg);
  font-size: var(--fs-xs);
  width: 280px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: all var(--t-med);
  z-index: 50;
  pointer-events: none;
}
.info-anchor:hover .info-tip,
.info-anchor:focus-within .info-tip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}
.info-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ink);
}
.info-tip__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-sm);
  display: block;
  margin-bottom: var(--s-2);
  color: #fff;
}
.info-tip__body {
  display: block;
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--fs-xs);
  line-height: 1.55;
}
.info-tip__body strong { color: #fff; font-weight: 600; }
.info-tip__body em { color: #fff; font-style: italic; }
/* Wider tooltip when the body carries multi-paragraph explanations. */
.info-tip:has(.info-tip__body) { width: 340px; max-width: 90vw; }
.info-tier {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  padding: 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  line-height: 1.4;
}
.info-tier:first-of-type { border-top: 0; }
.info-tier__threshold {
  font-family: var(--font-mono);
  color: var(--accent-soft);
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
}
.info-tier__sample { color: rgba(255, 255, 255, 0.85); font-style: italic; }
.info-tier--mid .info-tier__threshold { color: #FCD34D; }
.info-tier--high .info-tier__threshold { color: #FCA5A5; }
.info-tier--positive .info-tier__threshold { color: #6EE7B7; }

/* --------------------------------------------------------------------------
   22 · COMPONENTS — JSON OUTPUT
   -------------------------------------------------------------------------- */

.json-output {
  background: var(--ink);
  color: #E8EBF0;
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-lg);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.6;
  overflow-x: auto;
  max-height: 400px;
  margin: 0;
}

/* --------------------------------------------------------------------------
   24 · CHARTS — Inline SVG (canvas-free, pixel-perfect, JS-rendered)
   -------------------------------------------------------------------------- */

.chart-wrap {
  position: relative;
  width: 100%;
}
.chart-wrap--lg { height: 240px; }
.chart-wrap--md { height: 160px; }

.chart-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  font-size: var(--fs-sm);
  font-style: italic;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 8px,
    rgba(15, 23, 42, 0.025) 8px,
    rgba(15, 23, 42, 0.025) 16px
  );
  border-radius: var(--r-lg);
}

.svg-chart {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Chart hover tooltip — vertical guide + floating label */
.chart-tooltip {
  position: absolute;
  background: var(--ink);
  color: #fff;
  font-size: var(--fs-xs);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  transform: translate(-50%, -100%);
  margin-top: -8px;
  line-height: 1.5;
  display: none;
  z-index: 5;
}
.chart-tooltip.is-visible { display: block; }
.chart-tooltip__date {
  font-family: var(--font-mono);
  color: var(--accent-soft);
  margin-bottom: 2px;
  font-size: 10px;
}
.chart-tooltip__row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.chart-tooltip__row strong { color: #fff; font-family: var(--font-mono); }
.chart-tooltip__swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.chart-tooltip__guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--ink-3);
  opacity: 0.4;
  pointer-events: none;
  display: none;
}
.chart-tooltip__guide.is-visible { display: block; }

.svg-chart .grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 0; }
.svg-chart .axis-label { font-size: 11px; fill: var(--ink-3); font-family: var(--font-ui); }
.svg-chart .axis-y    { font-size: 11px; fill: var(--ink-3); font-family: var(--font-ui); }
.svg-chart .area      { opacity: 0.18; }
.svg-chart .line      { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.svg-chart .point     { fill: #fff; stroke-width: 1.6; r: 3; }
.svg-chart .bar       { rx: 2; }

.legend-toggles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-2);
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border-soft);
}

.legend-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-xs);
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  padding: 4px 10px;
  border-radius: var(--r-md);
  transition: all var(--t-fast);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}
.legend-toggle:hover { background: var(--surface-2); border-color: var(--border); }
.legend-toggle.is-off { opacity: 0.4; }
.legend-toggle.is-off .legend-toggle__swatch { background: var(--ink-4) !important; }
.legend-toggle__swatch {
  width: 10px;
  height: 10px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   24b · DASHBOARD-SPECIFIC — overview row layout & distribution bars
   -------------------------------------------------------------------------- */

/* Tri-column overview row : "All messages" / stacked KPI / Distribution */
.overview-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.85fr 1.6fr;
  gap: var(--s-5);
  align-items: stretch;
}
@media (max-width: 1100px) { .overview-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px)  { .overview-grid { grid-template-columns: 1fr; } }

.overview-stack {
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  gap: var(--s-4);
}

/* Big KPI with full-card sparkline (All messages) */
.kpi--big {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.kpi--big .kpi__value { font-size: 2.75rem; }
.kpi--big .kpi__chart {
  flex: 1;
  margin-top: auto;
  min-height: 160px;
}

/* Initial draw animation for sparkline path */
.svg-chart .line--anim {
  stroke-dasharray: var(--len, 1000);
  stroke-dashoffset: var(--len, 1000);
  animation: draw 800ms var(--ease) forwards;
}
@keyframes draw {
  to { stroke-dashoffset: 0; }
}

/* Compact KPI for stacked Removed / Kept */
.kpi--compact { padding: var(--s-5); }
.kpi--compact .kpi__value { font-size: 1.875rem; }

/* Distribution card with horizontal bars per category */
.dist-card {
  display: flex;
  flex-direction: column;
}
.dist-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-6) var(--s-8);
  flex: 1;
}
@media (max-width: 600px) { .dist-grid { grid-template-columns: 1fr; } }

.dist-cell {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px var(--s-3);
  align-items: center;
}

.dist-cell__icon {
  grid-row: 1 / 3;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
}
.dist-cell__icon svg { width: 18px; height: 18px; }

.dist-cell__label {
  font-size: var(--fs-sm);
  color: var(--ink);
  font-weight: 500;
}
.dist-cell__value {
  font-size: var(--fs-sm);
  color: var(--ink);
  font-weight: 600;
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  text-align: right;
}
.dist-cell__bar {
  grid-column: 2 / 4;
  grid-row: 2;
  height: 4px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
}
.dist-cell__bar-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width var(--t-slow) var(--ease);
}

.dist-cell[data-tone='positive'] .dist-cell__icon     { background: var(--positive-soft); color: var(--positive); }
.dist-cell[data-tone='positive'] .dist-cell__bar-fill { background: var(--positive); }
.dist-cell[data-tone='neutral']  .dist-cell__icon     { background: var(--neutral-soft); color: var(--neutral); }
.dist-cell[data-tone='neutral']  .dist-cell__bar-fill { background: var(--neutral); }
.dist-cell[data-tone='warn']     .dist-cell__icon     { background: var(--warn-soft); color: var(--warn); }
.dist-cell[data-tone='warn']     .dist-cell__bar-fill { background: var(--warn); }
.dist-cell[data-tone='danger']   .dist-cell__icon     { background: var(--danger-soft); color: var(--danger); }
.dist-cell[data-tone='danger']   .dist-cell__bar-fill { background: var(--danger); }
.dist-cell[data-tone='hold']     .dist-cell__icon     { background: var(--hold-soft); color: var(--hold); }
.dist-cell[data-tone='hold']     .dist-cell__bar-fill { background: var(--hold); }
.dist-cell[data-tone='reply']    .dist-cell__icon     { background: var(--accent-soft); color: var(--accent); }
.dist-cell[data-tone='reply']    .dist-cell__bar-fill { background: var(--accent); }
.dist-cell[data-tone='muted']    .dist-cell__icon     { background: var(--surface-3); color: var(--ink-3); }
.dist-cell[data-tone='muted']    .dist-cell__bar-fill { background: var(--ink-4); }

.dist-card__footer {
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
  font-size: var(--fs-xs);
  color: var(--ink-3);
}

/* Industry-average toggle (BG.ai-like) */
.industry-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  cursor: pointer;
  user-select: none;
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.industry-toggle input {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid var(--ink-4);
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--t-fast);
}
.industry-toggle input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.industry-toggle input:checked::after {
  content: '';
  width: 4px;
  height: 7px;
  border-right: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* Industry-average reference marker — dotted vertical line inside each bar */
.dist-cell__bar-ref {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  border-left: 2px dashed var(--ink-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med);
}
.dist-cell__bar { position: relative; }
.industry-on .dist-cell__bar-ref { opacity: 0.55; }

/* --------------------------------------------------------------------------
   24c · KPI HEADER refinements
   -------------------------------------------------------------------------- */

.kpi__delta-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
}
.kpi__delta-pill--down { background: var(--danger-soft); color: var(--danger); }
.kpi__delta-pill--up   { background: var(--positive-soft); color: var(--positive); }

.kpi__delta-line {
  margin-top: var(--s-2);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-xs);
  color: var(--ink-3);
}

/* --------------------------------------------------------------------------
   24d · MODERATION SECTION — Bodyguard.ai-style heading
   -------------------------------------------------------------------------- */

.bg-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-5);
  margin-top: var(--s-10);
}
.bg-section-head h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.012em;
  margin: 0;
}
.bg-section-head__link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--accent);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.bg-section-head__link:hover { color: var(--accent-hover); }
.bg-section-head__link svg { width: 14px; height: 14px; transition: transform var(--t-fast); }
.bg-section-head__link:hover svg { transform: translateX(2px); }

/* --------------------------------------------------------------------------
   24e · ASK AIDAN FAB
   -------------------------------------------------------------------------- */

.fab-ask {
  position: fixed;
  bottom: var(--s-5);
  right: var(--s-6);
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  height: 38px;
  padding: 0 var(--s-4) 0 var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-sm);
  color: var(--ink);
  cursor: pointer;
  z-index: 90;
  transition: all var(--t-fast);
}
.fab-ask:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.fab-ask__sparkle {
  color: var(--accent);
  display: inline-grid;
  place-items: center;
}
.fab-ask__sparkle svg { width: 16px; height: 16px; }
.fab-ask__pill {
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 2px 8px;
  font-size: var(--fs-xs);
  border-radius: var(--r-full);
  font-weight: 500;
  font-family: var(--font-mono);
}

/* AI Assistant Panel — slide-in drawer with chat UI */
.assistant-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 92vw);
  background: var(--surface);
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.10);
  z-index: 96;
  display: flex;
  flex-direction: column;
  animation: slide-in-right var(--t-med) var(--ease);
}
.assistant-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.assistant-panel__title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--ink);
}
.assistant-panel__title svg { color: var(--accent); width: 18px; height: 18px; }
.assistant-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-5);
}
.assistant-greeting {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
.assistant-greeting__avatar {
  width: 28px; height: 28px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent) 0%, #14B8A6 100%);
  color: #fff;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
}
.assistant-greeting__avatar svg { width: 14px; height: 14px; fill: currentColor; }
.assistant-greeting__text {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  color: var(--ink);
  font-weight: 500;
  line-height: 1.4;
}

.assistant-quota {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  margin-bottom: var(--s-4);
}
.assistant-quota__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s-3);
}
.assistant-quota__label {
  font-size: var(--fs-xs);
  color: var(--ink-2);
  font-weight: 500;
}
.assistant-quota__upsell {
  font-size: var(--fs-xs);
  color: var(--accent);
  font-weight: 500;
}
.assistant-quota__bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
}
.assistant-quota__bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
}
.assistant-quota__hint {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-top: var(--s-2);
}

.assistant-input {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-3);
}
.assistant-input textarea {
  width: 100%;
  border: 0;
  background: transparent;
  resize: none;
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  color: var(--ink);
  outline: none;
  min-height: 60px;
  padding: 0;
}
.assistant-input__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border-soft);
}
.assistant-input__filters {
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.assistant-input__send {
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  border: 0;
  cursor: pointer;
  transition: background var(--t-fast);
}
.assistant-input__send:hover { background: var(--accent-hover); }
.assistant-input__send svg { width: 14px; height: 14px; }

.assistant-suggestions__title {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-bottom: var(--s-2);
}
.assistant-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: var(--r-lg);
  padding: var(--s-2) var(--s-3);
  margin-bottom: var(--s-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: all var(--t-fast);
}
.assistant-suggestion:hover {
  background: var(--accent-soft-2);
  border-color: var(--accent);
}
.assistant-suggestion svg { width: 14px; height: 14px; opacity: 0.6; }

/* Chat bubble (assistant conversation history) */
.chat-msg {
  margin-bottom: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg);
  max-width: 92%;
}
.chat-msg--user {
  background: var(--accent-soft);
  margin-left: auto;
  border: 1px solid var(--accent-soft-2);
}
.chat-msg--bot {
  background: var(--surface-2);
  margin-right: auto;
  border: 1px solid var(--border-soft);
}
.chat-msg__role {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 4px;
}
.chat-msg--user .chat-msg__role { color: var(--accent-ink); }
.chat-msg__text {
  font-size: var(--fs-sm);
  color: var(--ink);
  line-height: 1.55;
  white-space: pre-wrap;
  margin: 0;
}

.dots-loading {
  display: inline-block;
  font-family: var(--font-mono);
  letter-spacing: 2px;
  animation: dots-pulse 1.2s var(--ease) infinite;
}
@keyframes dots-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* --------------------------------------------------------------------------
   24f · PLATFORM ICONS — multi-platform ready (YouTube, FB, IG, TikTok, X)
   -------------------------------------------------------------------------- */

.platform {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
}

.platform-icon {
  width: 22px;
  height: 22px;
  border-radius: var(--r-sm);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  color: #fff;
}
.platform-icon svg { width: 13px; height: 13px; fill: currentColor; }

.platform-icon--lg { width: 32px; height: 32px; border-radius: var(--r-md); }
.platform-icon--lg svg { width: 18px; height: 18px; }

.platform-icon--youtube   { background: var(--platform-youtube); }
.platform-icon--facebook  { background: var(--platform-facebook); }
.platform-icon--instagram { background: var(--platform-instagram); }
.platform-icon--tiktok    { background: var(--platform-tiktok); color: var(--platform-tiktok-ink); }
.platform-icon--x         { background: #000; }
.platform-icon--snapchat  { background: #FFFC00; color: #000; }

/* Source stack — Bodyguard-style: channel avatar (initials) + small
   platform-logo badge overlaid in the bottom-right corner with a ring
   matching the card background so it reads as floating on top. */
.source-stack {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: inline-block;
}
.source-stack__avatar {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
  object-fit: cover;
  background-color: var(--ink-3, #94A3B8);
}
.source-stack__badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 0 0 2px var(--surface, #fff);
}
.source-stack__badge svg { width: 9px; height: 9px; fill: currentColor; }
.source-stack__badge--youtube   { background: var(--platform-youtube); }
.source-stack__badge--facebook  { background: var(--platform-facebook); }
.source-stack__badge--instagram { background: var(--platform-instagram); color: var(--platform-instagram-ink); }
.source-stack__badge--tiktok    { background: var(--platform-tiktok); color: var(--platform-tiktok-ink); }
.source-stack__badge--x         { background: #000; }
.source-stack__badge--snapchat  { background: #FFFC00; color: #000; }

/* ====================================================================== */
/* Authors table — Bodyguard-style horizontal rows (responsive)            */
/* Desktop: a 5-column grid (Source / Auteur / Statut / Statistiques /     */
/* Actions) with a sticky-feel header. Narrow screens collapse each row    */
/* into a labeled card (the per-cell .atbl__rowlabel becomes visible).     */
/* ====================================================================== */
.atbl {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.atbl__head,
.atbl__row {
  display: grid;
  grid-template-columns: 56px minmax(0, 2.2fr) 104px minmax(0, 2fr) 116px;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-5);
}
.atbl__head {
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.atbl__th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  white-space: nowrap;
}
.atbl__th--actions { text-align: right; }

/* History variant — 6 columns (Source / Auteur / Action / Par / Date / État). */
.atbl--hist .atbl__head,
.atbl--hist .atbl__row {
  grid-template-columns: 52px minmax(0, 1.5fr) minmax(0, 1.3fr) minmax(0, 1.5fr) minmax(0, 1.3fr) 96px;
}

.atbl__row {
  border-top: 1px solid var(--border-soft);
  cursor: pointer;
  min-height: 60px;
  transition: background var(--t-fast);
}
.atbl__row:hover { background: var(--surface-2); }
.atbl__row--static { cursor: default; }

.atbl__trunc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.atbl__cell { min-width: 0; display: flex; align-items: center; gap: var(--s-2); }
.atbl__cell--actions { justify-content: flex-end; }
.atbl__acts { display: inline-flex; align-items: center; gap: var(--s-1); }
.atbl__rowlabel { display: none; }

.atbl__author { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.atbl__author-name {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.atbl-stats { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.atbl-stats__txt { min-width: 0; }
.atbl-stats__main { font-size: var(--fs-sm); color: var(--ink); line-height: 1.3; white-space: nowrap; }
.atbl-stats__main strong { font-weight: 700; }
.atbl-stats__pct { color: var(--ink-3); font-weight: 500; }
.atbl-stats__sub { font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.35; white-space: nowrap; }

/* Toxicity donut — hand-rolled SVG (no chart lib, per project convention).
   r = 15.915 makes the circumference ≈ 100, so stroke-dasharray maps 1:1 to
   the percentage. Rotated -90deg so the arc starts at the top. */
.atbl-donut { width: 34px; height: 34px; flex: 0 0 auto; transform: rotate(-90deg); }
.atbl-donut__track { fill: none; stroke: var(--surface-3); stroke-width: 3.4; }
.atbl-donut__bar { fill: none; stroke-width: 3.4; stroke-linecap: round; transition: stroke-dasharray var(--t-slow); }

@media (max-width: 860px) {
  .atbl {
    background: transparent;
    border: 0;
    box-shadow: none;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
  }
  .atbl__head { display: none; }
  .atbl__row {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    padding: var(--s-4) var(--s-5);
  }
  .atbl__cell {
    display: grid;
    grid-template-columns: 104px 1fr;
    gap: var(--s-4);
    align-items: center;
  }
  .atbl__cell + .atbl__cell {
    border-top: 1px dashed var(--border-soft);
    padding-top: var(--s-3);
  }
  .atbl__rowlabel {
    display: block;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
  }
  .atbl__cell--actions { justify-content: flex-start; }
}

/* ----- Smart-Reply draft block (Phase 1) ----- */
.smart-reply {
  margin: var(--s-3) 0 var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-left: 3px solid var(--brand, #6366F1);
  background: color-mix(in srgb, var(--brand, #6366F1) 5%, var(--surface, #fff));
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.smart-reply--approved  { border-left-color: #10B981; background: color-mix(in srgb, #10B981 6%, var(--surface, #fff)); }
.smart-reply--published { border-left-color: #059669; background: color-mix(in srgb, #059669 6%, var(--surface, #fff)); }
.smart-reply--rejected  { border-left-color: #6B7280; opacity: .6; }
.smart-reply--error     { border-left-color: var(--danger, #DC2626); background: color-mix(in srgb, var(--danger, #DC2626) 6%, var(--surface, #fff)); }
.smart-reply__header {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--ink-soft, #6B7280);
}
.smart-reply__icon { font-size: var(--fs-sm); }
.smart-reply__body {
  margin: 0;
  font-style: italic;
  color: var(--ink, #111827);
  line-height: 1.5;
}
.smart-reply__editor { display: flex; flex-direction: column; gap: var(--s-2); }
.smart-reply__editor-actions { display: flex; gap: var(--s-2); justify-content: flex-end; }
.smart-reply__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

.platform__name {
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.platform__handle {
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  margin-left: var(--s-2);
}

/* Platform pill — for "Coming soon" status badges */
.platform-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--t-fast);
  color: var(--ink-2);
}
.platform-pill:hover { border-color: var(--border-strong); color: var(--ink); }
.platform-pill[data-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.platform-pill[data-disabled='true']::after {
  content: 'Bientôt';
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-3);
  color: var(--ink-3);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-weight: 500;
  font-family: var(--font-mono);
}

/* Drawer (slide-in panel for author detail / future side-panels) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  z-index: 95;
  animation: fade-in var(--t-med) var(--ease);
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 92vw);
  background: var(--surface);
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.10);
  z-index: 96;
  display: flex;
  flex-direction: column;
  animation: slide-in-right var(--t-med) var(--ease);
}
@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.drawer__head {
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
}
.drawer__title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}
.drawer__subtitle {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  margin-top: 2px;
}
.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-6);
}
.drawer__close {
  background: var(--surface-2);
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink-2);
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.drawer__close:hover { background: var(--surface-3); color: var(--ink); }

/* Drawer message list */
.drawer-msg {
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border-soft);
}
.drawer-msg:last-child { border-bottom: 0; }
.drawer-msg__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-bottom: var(--s-2);
}
.drawer-msg__text {
  font-size: var(--fs-sm);
  color: var(--ink);
  line-height: 1.5;
}

/* Toast — short floating message for placeholder feedback */
.toast {
  position: fixed;
  bottom: var(--s-7);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all var(--t-med) var(--ease);
  z-index: 100;
  max-width: 420px;
  text-align: center;
}
.toast--show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Date range dropdown menu */
.range-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--s-2) 0;
  z-index: 95;
}
.range-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--s-2) var(--s-4);
  font-size: var(--fs-sm);
  color: var(--ink);
  cursor: pointer;
  transition: background var(--t-fast);
}
.range-menu__item:hover { background: var(--surface-2); }
.range-menu__item.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; }
.range-menu__sep { height: 1px; background: var(--border); margin: var(--s-2) 0; }

/* Bulk action bar — sticky bottom for table selection actions */
.bulk-bar {
  position: fixed;
  bottom: var(--s-5);
  left: calc(50% + var(--sidebar-w) / 2);
  transform: translateX(-50%);
  z-index: 90;
}
.bulk-bar__inner {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  padding: var(--s-3) var(--s-5);
  background: var(--ink);
  color: #fff;
  border-radius: var(--r-full);
  box-shadow: var(--shadow-lg);
}
.bulk-bar__count {
  font-size: var(--fs-sm);
  color: rgba(255, 255, 255, 0.85);
}
.bulk-bar__count strong { color: #fff; font-family: var(--font-mono); }
.bulk-bar .btn--ghost {
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.85);
  background: transparent;
}
.bulk-bar .btn--ghost:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* Tab badges (count chips on /authors tabs etc.) */
.tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  font-feature-settings: 'tnum';
}
.tab-badge--muted {
  background: var(--surface-3);
  color: var(--ink-3);
}

/* Author avatar (used on /authors and dashboard "Most toxic") */
.author-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

/* Source list (settings/sources) */
.source-list {
  display: flex;
  flex-direction: column;
}

.source-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border-soft);
}
.source-row:last-child { border-bottom: 0; }
.source-row:hover { background: var(--surface-2); }

.source-row__channel {
  min-width: 0;
}
.source-row__channel-name {
  font-weight: 500;
  color: var(--ink);
  font-size: var(--fs-sm);
}
.source-row__channel-meta {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-top: 2px;
}

.source-row__profile {
  font-size: var(--fs-sm);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}
.source-row__profile-star {
  color: var(--warn);
  font-size: 12px;
}

.source-row__health {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.source-row__health-pill {
  background: var(--positive-soft);
  color: var(--positive);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-weight: 500;
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
}

/* "Add source" platform picker */
.platform-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s-3);
  margin-top: var(--s-4);
}

/* --------------------------------------------------------------------------
   25 · UTILITIES
   -------------------------------------------------------------------------- */

.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack--tight { gap: var(--s-3); }
.stack--loose { gap: var(--s-5); }

.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }

.spaced {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: var(--s-6) 0;
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--ink-3); }

[data-reveal] { animation: rise 480ms var(--ease) backwards; }
[data-reveal='1'] { animation-delay: 40ms; }
[data-reveal='2'] { animation-delay: 110ms; }
[data-reveal='3'] { animation-delay: 180ms; }
[data-reveal='4'] { animation-delay: 250ms; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =========================================================================
 * 🟦 RESPONSIVE — Tablet & mobile overrides
 *
 * Two breakpoints:
 *   - ≤ 900px  : tablet — narrower padding, denser cards
 *   - ≤ 640px  : phone  — sidebar becomes bottom-nav, single-column,
 *                          iOS safe-area aware
 * ========================================================================= */

/* --- Tablet (≤ 900px) -------------------------------------------------- */
@media (max-width: 900px) {
  :root {
    --content-pad: 16px;
  }
  .page {
    padding: var(--s-4) var(--content-pad) var(--s-8);
  }
  .topbar {
    padding: 0 var(--content-pad);
  }
  .breadcrumb { font-size: var(--fs-xs); }
  .breadcrumb__crumb:not(.is-active) { display: none; }
  .topbar__pill {
    padding: 0 var(--s-3);
    font-size: var(--fs-xs);
  }
}

/* --- Phone (≤ 640px) --------------------------------------------------- */
@media (max-width: 640px) {
  :root {
    --content-pad: 12px;
    --sidebar-w: 0;
  }

  /* Single-column shell — sidebar is repositioned to the bottom */
  .app-shell {
    grid-template-columns: 1fr;
    min-height: 100dvh;
  }

  /* Sidebar → fixed bottom navigation bar */
  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    padding: var(--s-2) var(--s-3);
    padding-bottom: calc(var(--s-2) + env(safe-area-inset-bottom, 0px));
    border-right: none;
    border-top: 1px solid var(--border);
    background: rgba(250, 250, 247, 0.95);
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    z-index: 50;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar__brand,
  .sidebar__bottom { display: none; }

  .sidebar__nav {
    flex-direction: row;
    gap: var(--s-1);
    flex: 1;
    justify-content: space-around;
  }
  .sidebar__item {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }
  .sidebar__item.is-active::before {
    /* Replace the left vertical bar with a top horizontal bar */
    left: 50%;
    top: -4px;
    transform: translateX(-50%);
    width: 22px;
    height: 3px;
    border-radius: 0 0 var(--r-sm) var(--r-sm);
  }

  /* Topbar — show brand on the left (sidebar brand is hidden), shrink date pill */
  .topbar {
    height: auto;
    min-height: var(--topbar-h);
    padding: var(--s-2) var(--content-pad);
    gap: var(--s-2);
    flex-wrap: nowrap;
  }
  .topbar::before {
    content: 'Diwaller';
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--ink);
    margin-right: var(--s-2);
    letter-spacing: -0.01em;
  }
  .breadcrumb { display: none; }
  .topbar__actions { gap: var(--s-2); }
  .topbar__pill { height: 32px; padding: 0 var(--s-2); }
  .topbar__pill > span:not([x-text]) { display: none; }   /* hide leading icon-only pill labels */
  .topbar__icon-btn { width: 36px; height: 36px; }

  /* Page padding — keep content from being clipped by the bottom nav */
  .page {
    padding: var(--s-3) var(--content-pad);
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }
  .main { min-height: auto; }

  /* Cards & grids reflow */
  .card { padding: var(--s-3); }
  .kpi-grid,
  .row-2,
  .row-3-2,
  .dist-list,
  .dist-grid,
  .overview-grid,
  .settings-grid,
  .metrics-grid,
  .platform-picker {
    grid-template-columns: 1fr !important;
    gap: var(--s-2);
  }
  .settings-shell { grid-template-columns: 1fr !important; }
  .settings-nav {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: var(--s-2);
    padding-bottom: var(--s-2);
  }
  .settings-nav__item { flex-shrink: 0; }

  /* Tables — wrap horizontally when too wide */
  table { font-size: var(--fs-xs); }
  table thead { white-space: nowrap; }
  .dt-card,
  .source-list,
  .scrollable-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Forms */
  .input,
  textarea,
  select {
    font-size: 16px;        /* iOS no-zoom on focus requires ≥ 16px */
    width: 100%;
    box-sizing: border-box;
  }
  .field { width: 100%; }

  /* Buttons get bigger touch targets */
  .btn { min-height: 40px; }
  .btn--sm { min-height: 32px; }

  /* Floating Assistant Button — clear of the bottom nav */
  .fab-ask {
    bottom: calc(78px + env(safe-area-inset-bottom, 0px)) !important;
    right: 12px !important;
  }

  /* Assistant slide-in panel — full width, no side margin */
  .assistant-panel {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: var(--r-lg) var(--r-lg) 0 0 !important;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
    right: 0 !important;
    left: 0 !important;
    max-height: 75dvh;
  }

  /* Modal / drawer panels */
  .modal__panel { width: calc(100vw - 24px); max-width: 100%; }

  /* Auth shell (login/signup/setup-totp) */
  .auth-shell { padding: var(--s-4); }
  .auth-card {
    padding: var(--s-4);
    width: 100%;
    box-sizing: border-box;
  }

  /* Legal pages */
  .legal-shell { padding: var(--s-4) var(--s-3) calc(var(--s-6) + env(safe-area-inset-bottom, 0px)); }
}

/* ====================================================================== */
/* Moderation Analytics page — Bodyguard-style                              */
/* ====================================================================== */
.modan-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--s-6);
  align-items: start;
}
@media (max-width: 1024px) { .modan-shell { grid-template-columns: 1fr; } }

.modan-sidebar {
  position: sticky;
  top: var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
@media (max-width: 1024px) { .modan-sidebar { position: static; } }
.modan-sidebar__title {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  margin: 0 0 var(--s-1) 0;
}
.modan-sidebar__count {
  font-size: var(--fs-xs);
  color: var(--ink-2);
  margin-top: var(--s-2);
}
.modan-sidebar .filter-pill {
  width: 100%;
  justify-content: space-between;
}

.modan-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-4);
}
@media (max-width: 720px) { .modan-kpis { grid-template-columns: 1fr; } }

.modan-delta {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  font-size: var(--fs-xs);
  color: var(--ink-2);
}
.modan-delta--up   { color: var(--positive); }
.modan-delta--down { color: var(--danger); }
.modan-delta--bad-up   { color: var(--danger); }   /* removed went up = bad */
.modan-delta--good-up  { color: var(--positive); } /* kept went up = good  */

.modan-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--accent-soft);
  border-radius: var(--r-lg);
  border: 1px solid var(--accent-soft-2);
  font-size: var(--fs-sm);
  color: var(--accent-ink);
}
.modan-help a {
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: underline;
}

/* Donut */
.modan-donut {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--s-5);
  align-items: center;
}
@media (max-width: 540px) { .modan-donut { grid-template-columns: 1fr; } }
.modan-donut__legend {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.modan-donut__row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: var(--s-2);
  align-items: center;
  cursor: pointer;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-md);
  transition: background 100ms ease;
}
.modan-donut__row:hover { background: var(--surface-2); }
.modan-donut__row.is-active { background: var(--accent-soft); }
.modan-donut__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.modan-donut__label {
  font-size: var(--fs-sm);
  color: var(--ink-1);
}
.modan-donut__pct {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

/* Horizontal stacked bars (Distribution par source) */
.modan-hstack {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.modan-hstack__row {
  display: grid;
  grid-template-columns: 100px 1fr 80px;
  gap: var(--s-3);
  align-items: center;
}
.modan-hstack__label {
  font-size: var(--fs-sm);
  color: var(--ink-1);
  text-transform: capitalize;
}
.modan-hstack__bar {
  display: flex;
  height: 14px;
  background: var(--surface-2);
  border-radius: 7px;
  overflow: hidden;
}
.modan-hstack__seg {
  height: 100%;
  transition: filter 100ms ease;
}
.modan-hstack__seg:hover { filter: brightness(1.1); }
.modan-hstack__total {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-2);
  text-align: right;
}

/* Sub-classification 6-card grid */
.modan-subgrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-4);
}
@media (max-width: 800px) { .modan-subgrid { grid-template-columns: 1fr; } }
.modan-sub__title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-1);
  margin: 0 0 var(--s-3) 0;
}
.modan-sub__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}
.modan-sub__list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.modan-sub__row {
  display: grid;
  grid-template-columns: 1fr 60px;
  gap: var(--s-2);
  align-items: center;
}
.modan-sub__row--unknown { opacity: 0.5; }
.modan-sub__label {
  font-size: var(--fs-xs);
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}
.modan-sub__label-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modan-sub__bar {
  position: relative;
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  flex: 1 1 auto;
  overflow: hidden;
}
.modan-sub__bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 4px;
}
.modan-sub__val {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-2);
  text-align: right;
}

/* --- Very small phones (≤ 380px) -------------------------------------- */
@media (max-width: 380px) {
  .topbar__pill { display: none; }   /* date picker pushes off-screen — hide */
  .sidebar__item { width: 40px; height: 40px; }
}

/* =========================================================================
   Community analytics — page-specific layout (heatmap, source/author cards,
   language stacked bars, follower mini-chart). Builds on top of the modan-*
   primitives reused from analytics_moderation.html.
   ========================================================================= */

/* Section 1: active authors KPI + heatmap row */
.comm-active-row {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: var(--s-4);
  align-items: stretch;
}
@media (max-width: 720px) { .comm-active-row { grid-template-columns: 1fr; } }

.comm-kpis-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-4);
}
@media (max-width: 720px) { .comm-kpis-2 { grid-template-columns: 1fr; } }

/* --- Calendar heatmap --------------------------------------------------- */
.comm-heatmap-card { display: flex; flex-direction: column; gap: var(--s-3); }
.comm-heatmap-card__sub {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-left: auto;
}
.comm-heatmap {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: var(--s-2) 0;
  overflow-x: auto;
}
.comm-heatmap__svg { display: block; }
.comm-heatmap__cell {
  fill: var(--surface-2);
  transition: filter 120ms ease;
}
.comm-heatmap__cell:hover { filter: brightness(0.9); cursor: default; }
.comm-heatmap__cell[data-level="0"] { fill: var(--surface-2); }
.comm-heatmap__cell[data-level="1"] { fill: #BBE3D6; }
.comm-heatmap__cell[data-level="2"] { fill: #6BC4A7; }
.comm-heatmap__cell[data-level="3"] { fill: #2BA47C; }
.comm-heatmap__cell[data-level="4"] { fill: #0E7C5D; }
.comm-heatmap__month {
  font-size: 9px;
  fill: var(--ink-3);
  font-family: var(--font-ui);
}
.comm-heatmap__dlabel {
  font-size: 9px;
  fill: var(--ink-3);
  font-family: var(--font-ui);
}
.comm-heatmap__scale {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  margin-top: var(--s-2);
  font-size: var(--fs-xs);
}
.comm-heatmap__cell--legend {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--surface-2);
}
.comm-heatmap__cell--legend[data-level="0"] { background: var(--surface-2); }
.comm-heatmap__cell--legend[data-level="1"] { background: #BBE3D6; }
.comm-heatmap__cell--legend[data-level="2"] { background: #6BC4A7; }
.comm-heatmap__cell--legend[data-level="3"] { background: #2BA47C; }
.comm-heatmap__cell--legend[data-level="4"] { background: #0E7C5D; }

/* --- Display-by toggle (Source/Plateforme) ------------------------------ */
.comm-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}
.comm-toggle__label {
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.comm-toggle__btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  padding: 4px 10px;
  font-size: var(--fs-xs);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}
.comm-toggle__btn:hover:not(.is-disabled):not(.is-active) { background: var(--surface-2); }
.comm-toggle__btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-soft-2);
  color: var(--accent-ink);
  font-weight: 600;
}
.comm-toggle__btn.is-disabled,
.comm-toggle__btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* --- Source / Author cards (horizontal grid of 5) ----------------------- */
.comm-card-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--s-3);
  margin-top: var(--s-3);
}
@media (max-width: 1280px) { .comm-card-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px)  { .comm-card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .comm-card-grid { grid-template-columns: 1fr; } }

.comm-card-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

.comm-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-height: 120px;
  transition: box-shadow 120ms ease, transform 120ms ease;
}
.comm-card:hover { box-shadow: var(--shadow-xs); }
.comm-card--compact { min-height: 64px; padding: var(--s-2) var(--s-3); flex-direction: row; align-items: center; }
.comm-card--compact .comm-card__metric { font-size: var(--fs-lg); margin-left: auto; }
.comm-card--compact .comm-card__meta { display: none; }

.comm-card__link {
  display: block;
  color: inherit;
  text-decoration: none;
}
.comm-card__link:hover { text-decoration: none; }

.comm-card__head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}
.comm-card__avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}
.comm-card__platform--youtube   { box-shadow: 0 0 0 2px var(--platform-youtube)   inset; }
.comm-card__platform--facebook  { box-shadow: 0 0 0 2px var(--platform-facebook)  inset; }
.comm-card__platform--instagram { box-shadow: 0 0 0 2px var(--platform-instagram) inset; }
.comm-card__platform--tiktok    { box-shadow: 0 0 0 2px var(--platform-tiktok)    inset; }

.comm-card__title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}
.comm-card__title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.comm-card__title--2lines {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.comm-card__sub {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.comm-card__metric {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
}
.comm-card__pct {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--ink-3);
  font-family: var(--font-ui);
}
.comm-card__meta {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-xs);
}
.comm-card__delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--fs-xs);
  color: var(--ink-2);
}
.comm-card__delta.is-up   { color: var(--positive); }
.comm-card__delta.is-down { color: var(--danger); }
.comm-card__badge {
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.comm-card__badge--active    { background: var(--accent-soft); color: var(--accent-ink); }
.comm-card__badge--returning { background: var(--neutral-soft); color: var(--neutral); }
.comm-card__badge--new       { background: var(--positive-soft); color: var(--positive); }

/* --- Post cards (perception) — same shell, two-line title ------------- */
.comm-post-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-3);
}
.comm-post-list .comm-card { min-height: 96px; }

/* --- Followers empty state -------------------------------------------- */
.comm-empty {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: var(--s-8);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  background: var(--surface-2);
  border-radius: var(--r-md);
  min-height: 200px;
  gap: var(--s-2);
}

/* --- Language distribution (horizontal stacked) ----------------------- */
.comm-lang {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-3);
}
.comm-lang__row {
  display: grid;
  grid-template-columns: 120px 1fr 80px;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--fs-sm);
}
.comm-lang__label { color: var(--ink-2); }
.comm-lang__bar-outer {
  display: block;
  min-width: 4%;
}
.comm-lang__bar {
  display: flex;
  height: 12px;
  width: 100%;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
}
.comm-lang__seg {
  display: block;
  height: 100%;
}
.comm-lang__seg--mod    { background: var(--tone-undesirable); }
.comm-lang__seg--nonmod { background: var(--tone-positive); }
.comm-lang__total {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-2);
  text-align: right;
}
.comm-lang__legend {
  display: flex;
  gap: var(--s-3);
  margin-top: var(--s-3);
  font-size: var(--fs-xs);
  color: var(--ink-3);
}

/* =========================================================================
 * 27 · MESSAGES (logs.html) — Bodyguard-style comment cards
 *
 * One vertical card per comment. Each card stacks labeled rows
 * (Source / Message / "Commented on post:" / body / Action / Catégorie /
 * Classification / Sévérité / Langue / Publié le) and ends with the
 * "Bon exemple / Mauvais exemple" feedback strip.
 *
 * Class prefix `.msg-*`. Uses existing tokens (--ink-*, --surface-*,
 * --tone-*, --s-*) plus a tiny set of action-specific locals declared
 * inline (kept #bbf7d0/#15803d, removed #bae6fd/#0369a1, error red).
 * ========================================================================= */

.msg-results-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.msg-results-bar__count {
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.msg-results-bar__count strong { color: var(--ink); font-weight: 600; }
.msg-results-bar__group {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}
.msg-results-bar__page { font-size: var(--fs-xs); color: var(--ink-3); }
.msg-results-bar__page strong { color: var(--ink-2); font-weight: 600; }
.msg-results-bar__pp {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.msg-results-bar__pp-select {
  height: 28px;
  padding: 0 var(--s-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-xs);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--s-6);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 10px;
}
.msg-results-bar__select-all { font-size: var(--fs-xs); }

.msg-empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s-12) var(--s-4);
  text-align: center;
  color: var(--ink-3);
  font-style: italic;
  margin-bottom: var(--s-4);
}

.msg-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.msg-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  padding: var(--s-5) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  transition: box-shadow var(--t-fast), border-color var(--t-fast);
}
.msg-card:hover { box-shadow: var(--shadow-md); }
.msg-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft-2), var(--shadow-md);
}

.msg-card__corner {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
  display: flex;
  align-items: center;
  gap: var(--s-1);
  z-index: 2;
}
.msg-card__corner .iconbtn { width: 28px; height: 28px; }
.msg-card__corner .checkbox { margin-right: 2px; }

.msg-card__row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--s-4);
  align-items: start;
  padding: var(--s-1) 0;
}
.msg-card__row + .msg-card__row {
  border-top: 1px dashed var(--border-soft);
  padding-top: var(--s-3);
}

.msg-card__label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  white-space: nowrap;
}

.msg-card__value {
  min-width: 0;
  color: var(--ink);
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.msg-card__source { gap: var(--s-2); }
.msg-card__source-name { font-weight: 500; color: var(--ink); }

.msg-card__author { gap: var(--s-2); }
.msg-card__author-name {
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-card__avatar {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

.msg-card__post-context {
  margin: 0;
  font-style: italic;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.msg-card__post-context-author {
  font-style: normal;
  margin-left: var(--s-1);
  color: var(--accent-ink);
  font-weight: 500;
}

.msg-card__body-wrap {
  margin: var(--s-2) 0;
  padding: var(--s-3) var(--s-4);
  background: var(--surface-2);
  border-radius: var(--r-md);
  border-left: 3px solid var(--accent-soft-2);
}
.msg-card__body {
  margin: 0;
  font-size: var(--fs-base);
  color: var(--ink);
  font-weight: 500;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-card__body-actions {
  display: flex;
  gap: var(--s-3);
  margin-top: var(--s-2);
  font-size: var(--fs-xs);
}

.msg-card__date {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

.msg-card__lang {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--ink);
}
.msg-card__lang-flag { font-size: var(--fs-md); line-height: 1; }

/* ---- Badges (Action / Catégorie / Classification / Sévérité) ---------- */
.msg-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  height: 24px;
  padding: 0 var(--s-3);
  border-radius: var(--r-md);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  font-family: var(--font-ui);
  background: var(--surface-3);
  color: var(--ink-2);
}
.msg-badge--plus {
  background: var(--surface-3);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 0 var(--s-2);
  height: 20px;
}

/* Action — Bodyguard parity:
 *   kept    → green-200 / green-700
 *   removed → cyan-200 / cyan-700  (action-taken semantics, NOT danger)
 *   pending → grey
 *   error   → red    */
.msg-badge--action-kept    { background: #bbf7d0; color: #15803d; }
.msg-badge--action-removed { background: #bae6fd; color: #0369a1; }
.msg-badge--action-pending { background: var(--surface-3); color: var(--ink-2); }
.msg-badge--action-error   { background: var(--danger-soft); color: var(--danger); }

/* Tone (Catégorie) — uses --tone-* tokens with light bg + darker text. */
.msg-badge--tone-positive    { background: #dcfce7; color: #166534; }
.msg-badge--tone-neutral     { background: #dbeafe; color: #1e40af; }
.msg-badge--tone-criticism   { background: #f3e8ff; color: #6b21a8; }
.msg-badge--tone-hateful     { background: #fef3c7; color: #92400e; }
.msg-badge--tone-hate-speech { background: #ffedd5; color: #9a3412; }
.msg-badge--tone-undesirable { background: #fee2e2; color: #991b1b; }

/* Severity */
.msg-badge--sev-none   { background: var(--surface-3); color: var(--ink-3); }
.msg-badge--sev-medium { background: #fde68a; color: #a16207; }
.msg-badge--sev-high   { background: #fecaca; color: #b91c1c; }

/* ---- Feedback row (Bon / Mauvais exemple) ----------------------------- */
.msg-card__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  padding-top: var(--s-4);
  margin-top: var(--s-2);
  border-top: 1px solid var(--border);
}
.msg-card__fb-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 32px;
  padding: 0 var(--s-3);
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.msg-card__fb-btn svg { width: 14px; height: 14px; }
.msg-card__fb-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--border-strong); }
.msg-card__fb-btn:disabled { opacity: 0.6; pointer-events: none; }
.msg-card__fb-btn--active {
  border-width: 1.5px;
  font-weight: 600;
}
.msg-card__fb-btn--good.msg-card__fb-btn--active {
  background: #dcfce7;
  border-color: #15803d;
  color: #15803d;
}
.msg-card__fb-btn--bad.msg-card__fb-btn--active {
  background: #fee2e2;
  border-color: #b91c1c;
  color: #b91c1c;
}
.msg-card__fb-counts {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.msg-card__fb-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
}
.msg-card__fb-count svg { width: 12px; height: 12px; opacity: 0.6; }
.msg-card__fb-count--good { color: #15803d; }
.msg-card__fb-count--good svg { opacity: 0.9; }
.msg-card__fb-count--bad  { color: #b91c1c; }
.msg-card__fb-count--bad svg { opacity: 0.9; }

/* ---- Pagination footer ----------------------------------------------- */
.msg-pagination {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  margin-top: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  box-shadow: var(--shadow-xs);
}
.msg-pagination__sep { color: var(--ink-4); }
.msg-pagination__group {
  display: flex;
  gap: var(--s-1);
  margin-left: auto;
}

/* =========================================================================
   Messages table — Bodyguard-style horizontal table (`.msg-table`).

   One <tbody> per message: a compact 56px main row + a full-width,
   collapsible detail row. Reuses `.msg-badge`, `.source-stack`,
   `.smart-reply` and `.msg-card__fb-*` so the look stays consistent.
   ========================================================================= */
.msg-table-wrap {
  width: 100%;
  margin-top: var(--s-4);
  overflow-x: auto;
}
.msg-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  font-size: var(--fs-sm);
  color: var(--ink);
}

/* ---- Header --------------------------------------------------------- */
.msg-table__th {
  height: 32px;
  padding: var(--s-2) var(--s-3);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1;
  color: var(--ink-3);
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.msg-table__th--check   { width: 1%; padding-right: var(--s-2); }
.msg-table__th--msg     { width: 40%; min-width: 260px; }
.msg-table__th--actions { width: 1%; }

/* ---- Body rows ------------------------------------------------------ */
.msg-table__group { transition: background-color var(--t-fast); }
.msg-table__group:hover { background: var(--surface-2); }
.msg-table__group.is-selected { background: var(--accent-soft); }
.msg-table__row { cursor: pointer; }
.msg-table__td {
  height: 56px;
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.msg-table__group:last-child .msg-table__td { border-bottom: 0; }
.msg-table__row.is-expanded .msg-table__td { border-bottom-color: transparent; }
.msg-table__td--check   { width: 1%; }
.msg-table__td--actions { width: 1%; }
.msg-table__td--date    { white-space: nowrap; }

/* ---- Source cell ---------------------------------------------------- */
.msg-cell-source { display: flex; align-items: center; gap: var(--s-2); }
.msg-cell-source__name {
  font-size: var(--fs-sm);
  color: var(--ink);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Message cell --------------------------------------------------- */
.msg-cell-msg { display: flex; flex-direction: column; gap: 3px; padding: var(--s-1) 0; }
.msg-cell-msg__author { display: flex; align-items: center; gap: var(--s-2); }
.msg-cell-msg__avatar {
  width: 18px; height: 18px;
  border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.55rem; font-weight: 700; color: #fff;
  flex-shrink: 0; line-height: 1;
}
.msg-cell-msg__author-name { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); }
.msg-cell-msg__body {
  margin: 0;
  font-size: var(--fs-sm);
  line-height: 1.35;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Classification +1 inline --------------------------------------- */
.msg-cell-class { display: inline-flex; align-items: center; gap: var(--s-1); }

/* ---- Date cell ------------------------------------------------------ */
.msg-table__date { font-size: var(--fs-xs); color: var(--ink-2); white-space: nowrap; }

/* ---- Per-row actions ------------------------------------------------ */
.msg-table__actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.msg-table__actions .iconbtn { width: 28px; height: 28px; }
.msg-table__chevron svg { transition: transform var(--t-fast); }
.msg-table__chevron.is-open svg { transform: rotate(180deg); }

/* ---- Detail (expandable) row --------------------------------------- */
.msg-table__detail-cell {
  padding: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.msg-table__group:last-child .msg-table__detail-cell { border-bottom: 0; }
.msg-detail {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4) var(--s-4);
}
.msg-detail__context { margin: 0; font-size: var(--fs-xs); color: var(--ink-3); }
.msg-detail__context-label { color: var(--ink-2); font-weight: 500; }
.msg-detail__body-wrap { display: flex; flex-direction: column; gap: var(--s-1); }
.msg-detail__body { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--ink); white-space: pre-wrap; }
.msg-detail__feedback { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

/* ---- Posts table extras (`.msg-table` reused on /posts) ------------- */
.msg-table__row:hover { background: var(--surface-2); }
.msg-table__th--title { width: 38%; min-width: 240px; }
.msg-table__td--title { max-width: 0; }
.post-cell-title-wrap { display: flex; align-items: flex-start; gap: var(--s-2); }
.post-cell-title {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--ink);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-cell-title__tag { flex-shrink: 0; font-size: 10px; }
.post-score-wrap { display: inline-flex; align-items: center; gap: var(--s-2); }
.post-score-pct { font-size: var(--fs-xs); white-space: nowrap; }
.post-stat { display: flex; align-items: center; gap: var(--s-2); }
.post-donut { position: relative; width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; }
.post-donut::after { content: ''; position: absolute; inset: 7px; background: var(--surface); border-radius: 50%; }
.post-stat__text { font-size: var(--fs-xs); color: var(--ink); white-space: nowrap; }

/* ---- Responsive ------------------------------------------------------ */
@media (max-width: 720px) {
  .msg-card { padding: var(--s-4); }
  .msg-card__row {
    grid-template-columns: 1fr;
    gap: var(--s-1);
  }
  .msg-card__row + .msg-card__row { padding-top: var(--s-2); }
  .msg-card__corner { top: var(--s-2); right: var(--s-2); }
  .msg-card__actions { gap: var(--s-2); }
  .msg-card__fb-counts { margin-left: 0; width: 100%; justify-content: flex-end; }
  .msg-results-bar { flex-direction: column; align-items: stretch; }
  .msg-results-bar__group { justify-content: space-between; }
}

/* =========================================================================
   Authors page — `.auth-card` (Bodyguard-style vertical card).

   Structurally identical to `.msg-card`; this block holds the small
   deltas (full-row click, no body block, source-pill row tweaks) so the
   two pages stay visually consistent without surprising each other.
   ========================================================================= */
.auth-card {
  cursor: pointer;
}
.auth-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
/* Make the source pill row read as a single inline group. */
.auth-card .msg-card__source { gap: var(--s-2); }
.auth-card .msg-card__source-name { font-weight: 500; color: var(--ink); }

/* ---- Author detail — header card source pill -------------------------- */
.auth-header-card { position: relative; }
.auth-header-card__source {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px var(--s-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  color: var(--ink-2);
  margin-bottom: var(--s-4);
  max-width: max-content;
}
.auth-header-card__source-label {
  font-weight: 500;
  color: var(--ink);
}


/* =========================================================================
   Publications page — `.post-card` (Bodyguard-style vertical card).

   Structurally identical to `.auth-card` (which itself aliases `.msg-card`
   with the click-through tweak). The post-specific deltas live here:
     - `.post-card__title` clamps the post title to 3 lines (matches
       Bodyguard, prevents long YouTube titles from blowing up the row).
     - `.post-score--{low|medium|high}` badges colour the auto-computed
       post-score (Faible / Moyen / Élevé).
     - `.post-detail-head` / `.post-card--detail` style the detail-page
       header card variant.
     - `.post-detail-comments` adds top spacing before the comments list.
   ========================================================================= */
.post-card {
  cursor: pointer;
}
.post-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.post-card .msg-card__source { gap: var(--s-2); }
.post-card .msg-card__source-name { font-weight: 500; color: var(--ink); }

/* Post title — clamp to 3 lines (Bodyguard idiom). */
.post-card__title {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
  font-size: var(--fs-sm);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
/* Detail-page variant — full title, no clamp, slightly larger. */
.post-card__title--detail {
  -webkit-line-clamp: unset;
  font-size: var(--fs-md);
  line-height: 1.45;
}

/* ---- Post score badges (low / medium / high) ---------------------------- */
.post-score {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-full);
  display: inline-block;
  line-height: 1.4;
  border: 1px solid transparent;
}
.post-score--low {
  background: #bbf7d0;
  color: #15803d;
  border-color: rgba(21, 128, 61, 0.15);
}
.post-score--medium {
  background: #fde68a;
  color: #a16207;
  border-color: rgba(161, 98, 7, 0.15);
}
.post-score--high {
  background: #fecaca;
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.15);
}

/* ---- Video detail page ------------------------------------------------- */
.post-detail-head {
  margin-bottom: var(--s-6);
}
.post-card--detail {
  /* Detail-page header card mirrors a list card but isn't a navigation
     surface — opt out of the hover affordance. The corner external-link
     button stays interactive. */
  cursor: default;
}
.post-card--detail:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}
.post-detail-comments {
  margin-top: var(--s-6);
}
.post-detail-comments .section__head {
  margin-bottom: var(--s-4);
}
