/* ──────────────────────────────────────────────────────────────────────────
 * PostNimble — single stylesheet
 * ──────────────────────────────────────────────────────────────────────────
 *
 * TABLE OF CONTENTS
 *   1. Tokens
 *      1.1 Color — primitive scale
 *      1.2 Color — semantic
 *      1.3 Type
 *      1.4 Space
 *      1.5 Radius
 *      1.6 Shadow
 *      1.7 Motion
 *      1.8 Layout (z-index, container, nav)
 *      1.9 Compatibility aliases — old names mapped to new tokens
 *   2. Base (typography reset, body, focus rings)
 *   3. Components
 *      3.0 Legacy primitives (in-place migration to canonical names — kept stable
 *           because templates reference these selectors directly)
 *      3.1 Focus rings (global)
 *      3.2 Buttons — variants, sizes, states
 *      3.3 Form fields — checkbox, radio, toggle, search, file, helper, error
 *      3.4 Status pills — canonical token mapping
 *      3.5 Modal (generic)
 *      3.6 Toasts
 *      3.7 Empty state
 *      3.8 Avatar
 *      3.9 Tables — sticky header, sortable, row-actions, tabular numerals
 *      3.10 Tabs (canonical)
 *      3.11 Card variants
 *      3.12 Mention chip
 *      3.13 Slide-out alignment
 *      3.14 Badge — neutral default + sizes
 *      3.15 Density modes
 *   4. Page-specific overrides
 *      4.1 Auth shell (login, forgot, reset, terms, platform, change-password, errors)
 *      4.2 Marketing landing (public homepage)
 *      4.3 Run lifecycle (run-detail, review, schedule)
 *      4.4 Dashboard (calendar-first)
 *      4.5 Stragglers (legacy class aliases for sparse templates)
 *
 * Naming convention:
 *   --color-*        primitive scale steps. Private. Components must NOT reference these directly.
 *   --surface-*      semantic surfaces (canvas, raised, chrome, overlay).
 *   --text-*         semantic text colors.
 *   --border-*       semantic borders.
 *   --accent / --accent-strong / --accent-soft-*    brand accent (canonical = #C4B5FD per brief §3).
 *   --status-*-bg / --status-*-text                  per-phase status pills.
 *   --feedback-*-bg / --feedback-*-text              flash messages.
 *   --space-*, --radius-*, --shadow-*, --motion-*    cross-cutting scales.
 *   Old names (--green, --bg, --muted, --shadow, etc.) are kept as aliases in §1.9
 *   so legacy components keep working until they migrate to the canonical names.
 * ──────────────────────────────────────────────────────────────────────── */

/* 1.1 Color — primitive scale (private; do not reference from components) */
:root {
  /* Neutral — warm, not blue-cool. Anchors the chrome of the app. */
  --color-ink-50:  #FAFAF7;
  --color-ink-100: #F4F2EE;
  --color-ink-200: #E8E5DF;
  --color-ink-300: #D4D0C8;
  --color-ink-400: #A8A49B;
  --color-ink-500: #8A8893;
  --color-ink-600: #5A5862;
  --color-ink-700: #2E2D34;
  --color-ink-800: #14151A;
  --color-ink-900: #0B0B0F;

  /* Violet — accent ramp anchored on brief §3 canonical #C4B5FD (Violet-300). */
  --color-violet-50:  #F5F3FF;
  --color-violet-100: #EDE9FE;
  --color-violet-200: #DDD6FE;
  --color-violet-300: #C4B5FD;   /* canonical brand accent (brief §3) */
  --color-violet-400: #A78BFA;
  --color-violet-500: #8B5CF6;
  --color-violet-600: #7C3AED;   /* operational primary fill (white text on top) */
  --color-violet-700: #6D28D9;
  --color-violet-800: #5B21B6;

  /* Status — saturated for icons/text; -50 for pill backgrounds (§5.2: never bright primary fills) */
  --color-green-50:  #ECFDF5;
  --color-green-500: #16A34A;
  --color-green-700: #15803D;
  --color-amber-50:  #FFF7ED;
  --color-amber-500: #D97706;
  --color-amber-700: #B45309;
  --color-red-50:    #FEF2F2;
  --color-red-500:   #DC2626;
  --color-red-700:   #B91C1C;
  --color-blue-50:   #EFF6FF;
  --color-blue-500:  #2563EB;
  --color-blue-700:  #1D4ED8;
}

/* 1.2 Color — semantic (public; components reference these) */
:root {
  /* Surfaces */
  --surface-canvas:  var(--color-ink-50);    /* page bg — warm off-white per brief §3 */
  --surface-raised:  #FFFFFF;                /* cards, modals, dropdowns */
  --surface-sunken:  var(--color-ink-100);   /* code blocks, inset panels */
  --surface-chrome:  var(--color-ink-900);   /* top nav, dark surfaces */
  --surface-overlay: rgba(11, 11, 15, 0.55); /* modal backdrop */

  /* Text */
  --text-primary:       var(--color-ink-900);
  --text-secondary:     var(--color-ink-600);
  --text-tertiary:      var(--color-ink-500);
  --text-disabled:      var(--color-ink-400);
  --text-on-chrome:     #FFFFFF;
  --text-on-chrome-dim: rgba(255, 255, 255, 0.72);
  --text-on-accent:     #FFFFFF;
  --text-link:          var(--color-violet-700);

  /* Borders */
  --border-subtle:  var(--color-ink-200);
  --border-default: var(--color-ink-300);
  --border-strong:  var(--color-ink-600);
  --border-focus:   var(--color-violet-500);

  /* Accent — canonical = #C4B5FD; -strong is the operational fill that meets AA contrast for white text */
  --accent:           var(--color-violet-300);  /* canonical brand color (brief §3) */
  --accent-strong:    var(--color-violet-600);  /* primary CTA fill on light surfaces */
  --accent-stronger:  var(--color-violet-700);  /* hover / pressed */
  --accent-soft-bg:   var(--color-violet-50);
  --accent-soft-text: var(--color-violet-700);
  --accent-on-dark:   var(--color-violet-300);  /* nav active underline on dark chrome */

  /* Status — pill bg + readable text */
  --status-generating-bg:   var(--color-amber-50);
  --status-generating-text: var(--color-amber-700);
  --status-review-bg:       var(--color-violet-50);
  --status-review-text:     var(--color-violet-700);
  --status-publishing-bg:   var(--color-blue-50);
  --status-publishing-text: var(--color-blue-700);
  --status-published-bg:    var(--color-green-50);
  --status-published-text:  var(--color-green-700);
  --status-failed-bg:       var(--color-red-50);
  --status-failed-text:     var(--color-red-700);
  --status-scheduled-bg:    var(--color-ink-100);
  --status-scheduled-text:  var(--color-ink-700);

  /* Feedback (flash) */
  --feedback-success-bg:   var(--color-green-50);
  --feedback-success-text: var(--color-green-700);
  --feedback-warning-bg:   var(--color-amber-50);
  --feedback-warning-text: var(--color-amber-700);
  --feedback-error-bg:     var(--color-red-50);
  --feedback-error-text:   var(--color-red-700);
  --feedback-info-bg:      var(--color-blue-50);
  --feedback-info-text:    var(--color-blue-700);

  /* Focus ring — single source of truth for every interactive element (brief §10) */
  --focus-ring:        0 0 0 3px rgba(139, 92, 246, 0.35);
  --focus-ring-offset: 2px;
}

/* 1.3 Type
 * Inter (UI) and Source Serif 4 (blog body) per brief §3.
 * Self-hosted .woff2 @font-face declarations live in the Base layer (§2).
 * Tabular numerals are opt-in via .num-tabular helper or component CSS.
 */
:root {
  --font-sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --font-mono:  ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --text-xs:   0.75rem;    /* 12px — micro labels, table meta */
  --text-sm:   0.8125rem;  /* 13px — secondary UI text, helper */
  --text-base: 0.9375rem;  /* 15px — default body, form input */
  --text-md:   1rem;       /* 16px — emphasis body */
  --text-lg:   1.125rem;   /* 18px — small section heads */
  --text-xl:   1.375rem;   /* 22px — page title */
  --text-2xl:  1.75rem;    /* 28px — dashboard hero numbers */
  --text-3xl:  2.25rem;    /* 36px — marketing hero (landing only) */

  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  --leading-tight:   1.2;
  --leading-snug:    1.4;
  --leading-normal:  1.55;
  --leading-relaxed: 1.75;

  --tracking-tight:  -0.01em;
  --tracking-normal: 0;
  --tracking-wide:   0.04em;
}

/* 1.4 Space — 4-base scale */
:root {
  --space-0:  0;
  --space-1:  0.25rem;   /*  4px */
  --space-2:  0.5rem;    /*  8px */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */
  --space-24: 6rem;      /* 96px */
}

/* 1.5 Radius */
:root {
  --radius-xs:   2px;
  --radius-sm:   4px;
  --radius-md:   6px;     /* form inputs, small buttons */
  --radius-lg:   8px;     /* cards, default buttons */
  --radius-xl:   12px;    /* modals, slide-outs */
  --radius-2xl:  16px;    /* marketing hero cards */
  --radius-pill: 9999px;  /* pills, FABs, avatar */
}

/* 1.6 Shadow — neutral, not violet-tinted */
:root {
  --shadow-none:  none;
  --shadow-xs:    0 1px 2px rgba(11, 11, 15, 0.04);
  --shadow-sm:    0 1px 3px rgba(11, 11, 15, 0.06), 0 1px 2px rgba(11, 11, 15, 0.04);
  --shadow-md:    0 4px 12px rgba(11, 11, 15, 0.08), 0 1px 3px rgba(11, 11, 15, 0.05);
  --shadow-lg:    0 12px 28px rgba(11, 11, 15, 0.12), 0 2px 6px rgba(11, 11, 15, 0.06);
  --shadow-xl:    0 24px 56px rgba(11, 11, 15, 0.18), 0 4px 12px rgba(11, 11, 15, 0.08);
  --shadow-focus: var(--focus-ring);
}

/* 1.7 Motion */
:root {
  --motion-instant: 80ms;
  --motion-fast:    140ms;   /* hover, color shifts */
  --motion-base:    200ms;   /* dropdown open, modal fade */
  --motion-slow:    320ms;   /* slide-out drawer */
  --motion-slower:  500ms;   /* progress bar fills */

  --easing-standard:    cubic-bezier(0.2, 0, 0, 1);
  --easing-emphasized:  cubic-bezier(0.2, 0, 0, 1.05);
  --easing-decelerate:  cubic-bezier(0, 0, 0, 1);
  --easing-accelerate:  cubic-bezier(0.3, 0, 1, 1);

  --motion-pulse: 1.4s ease-in-out infinite;
  --motion-spin:  700ms linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-instant: 0ms;
    --motion-fast:    0ms;
    --motion-base:    0ms;
    --motion-slow:    0ms;
    --motion-slower:  0ms;
  }
}

/* 1.8 Layout — z-index, container, nav, slide-out */
:root {
  --z-base:     0;
  --z-sticky:   100;   /* top nav */
  --z-dropdown: 200;   /* client switcher, user menu */
  --z-fab:      300;   /* feedback FAB, AI assistant FAB */
  --z-overlay:  400;   /* modal backdrop, slide-out backdrop */
  --z-modal:    500;   /* modal content */
  --z-toast:    600;   /* toasts (bottom-right) */
  --z-popover:  700;   /* tooltips, mention dropdown */

  --container-max:    1280px;
  --container-pad-x:  var(--space-6);
  --nav-height:       56px;
  --rail-width:       280px;
  --slide-out-width:  480px;
}

/* 1.9 Compatibility aliases — phase 1 of redesign.
 *     Old names are kept so legacy components keep working unchanged.
 *     Components migrate to the canonical names above during the §5.2 pass,
 *     and these aliases get retired in §9.5 (final refactor). */
:root {
  --green:       var(--color-violet-600);   /* primary action fill — value unchanged (#7C3AED) */
  --green-light: var(--color-violet-100);   /* tint — value unchanged (#EDE9FE) */
  --green-mid:   var(--color-violet-700);   /* hover/pressed — value unchanged (#6D28D9) */
  --emerald:     var(--color-green-500);    /* legacy: was #10B981 → now #16A34A */
  --emerald-lt:  var(--color-green-50);     /* legacy: was #D1FAE5 → now #ECFDF5 */

  --bg:          var(--surface-canvas);     /* CHANGED: lavender #F5F3FF → warm off-white #FAFAF7 (brief §3) */
  --white:       var(--surface-raised);
  --text:        var(--text-primary);       /* CHANGED: #111827 → #0B0B0F (slight contrast lift) */
  --muted:       var(--text-secondary);     /* CHANGED: #6B7280 → #5A5862 (slight contrast lift) */
  --border:      var(--border-subtle);      /* CHANGED: violet-tinted #DDD6FE → warm neutral #E8E5DF */

  --red:         var(--color-red-500);
  --amber:       var(--color-amber-500);
  --blue:        var(--color-blue-500);

  --radius:      var(--radius-lg);          /* unchanged: 8px */
  --shadow:      var(--shadow-sm);          /* CHANGED: violet-tinted → neutral */
}

/* ──────────────────────────────────────────────────────────────────────────
 * §2 — Base (typography reset, body, focus rings, link defaults)
 * ──────────────────────────────────────────────────────────────────────── */

/* 2.1 Web fonts — self-hosted variable .woff2 (brief §3, §4) */
@font-face {
  font-family: "Inter";
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/InterVariable.woff2") format("woff2-variations"),
       url("./fonts/InterVariable.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Inter-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Inter-Medium.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Inter-SemiBold.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/Inter-Bold.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/SourceSerif4Variable.woff2") format("woff2-variations"),
       url("./fonts/SourceSerif4Variable.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/SourceSerif4-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url("./fonts/SourceSerif4-Bold.woff2") format("woff2");
}

/* 2.2 Reset + body */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font-sans);
  background: var(--surface-canvas);
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

a { color: var(--text-link); }
a:hover { text-decoration: underline; }

img, svg, video { max-width: 100%; }

/* Selection */
::selection {
  background: var(--accent-soft-bg);
  color: var(--accent-soft-text);
}


/* ──────────────────────────────────────────────────────────────────────────
 * §3 — Components
 * §3.0 — Legacy primitives (nav, cards, buttons, badges, tables, …)
 *   These selectors are referenced directly by Jinja templates and inline
 *   styles. They consume tokens via the §1.9 alias layer (--green, --bg,
 *   --muted, --text, --border, --shadow, etc.). Kept stable until templates
 *   migrate to the canonical names in §3.1+.
 * ──────────────────────────────────────────────────────────────────────── */

/* ── Nav ──────────────────────────────────────────────────────────────────── */
nav {
  background: #0C0A1A;
  color: white;
  padding: 0 16px;
  display: flex;
  align-items: center;
  min-height: 56px;
  gap: 16px;
  border-bottom: 1px solid rgba(124,58,237,0.2);
  flex-wrap: wrap;
}
nav a { color: rgba(255,255,255,0.8); text-decoration: none; font-size: 14px; }
nav a:hover { color: white; }
nav a.nav-active { color: white; font-weight: 600; border-bottom: 2px solid var(--green); padding-bottom: 2px; }

nav .spacer { flex: 1; min-width: 8px; }

/* Mobile nav — stack on narrow screens */
@media (max-width: 600px) {
  nav { gap: 10px; padding: 8px 12px; }
  nav .logo-wordmark { max-width: 120px; font-size: 14px; }
  nav > a { font-size: 13px; }
}

/* ── Logo / client switcher ── */
.logo-switcher { position: relative; }

.logo-btn {
  background: rgba(124,58,237,0.12);
  border: 1px solid rgba(124,58,237,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 8px;
  transition: background 0.15s;
}
.logo-btn:hover, .logo-switcher.open .logo-btn { background: rgba(124,58,237,0.22); }

.logo-cheetah {
  width: 24px;
  height: auto;
  flex-shrink: 0;
  opacity: 0.95;
}

.logo-wordmark {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.2px;
  color: #fff;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logo-sub {
  color: rgba(255,255,255,0.45);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  line-height: 1;
  align-self: flex-end;
  margin-bottom: 1px;
}
.logo-caret {
  color: rgba(255,255,255,0.4);
  font-size: 10px;
}

.logo-dropdown {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(124,58,237,0.15);
  min-width: 220px;
  z-index: 999;
  overflow: hidden;
}
.logo-switcher.open .logo-dropdown { display: block; }

.logo-dd-item {
  width: 100%;
  text-align: left;
  padding: 10px 14px 10px 10px;
  font-size: 13px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  transition: background 0.1s;
}
.logo-dd-item:hover { background: var(--green-light); }
.logo-dd-active { background: var(--green-light) !important; }
.logo-dd-check {
  width: 14px; font-size: 12px; color: var(--green);
  flex-shrink: 0; line-height: 1.4;
}
.logo-dd-section { border-top: 1px solid var(--border); }

/* Rich two-line row used by the company switcher */
.logo-dd-row { min-width: 240px; }
.logo-dd-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.logo-dd-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  line-height: 1.3;
}
.logo-dd-active .logo-dd-name { color: var(--green-mid); }
.logo-dd-cat {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
  line-height: 1.3;
}
.logo-dd-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.logo-dd-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--emerald-lt);
  color: #065F46;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 10.5px;
  letter-spacing: 0.01em;
}

/* ── Page layout ──────────────────────────────────────────────────────────── */
.page { max-width: 1100px; margin: 0 auto; padding: 28px 20px 60px; }

/* ── Flash messages ───────────────────────────────────────────────────────── */
.flash { padding: 11px 16px; border-radius: var(--radius); margin-bottom: 16px;
         font-size: 14px; border: 1px solid transparent; }
.flash.success { background: var(--green-light); border-color: #C4B5FD; color: var(--green-mid); }
.flash.error   { background: #FEE2E2; border-color: #FCA5A5; color: var(--red); }
.flash.info    { background: #DBEAFE; border-color: #93C5FD; color: var(--blue); }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: var(--green); }
.card h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--muted);
           text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
input[type="text"], input[type="url"], input[type="datetime-local"],
textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: white;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}
textarea { resize: vertical; }

.form-row { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s, background 0.15s, transform 0.1s;
}
.btn:hover { opacity: 0.88; }
.btn-primary  { background: var(--green); color: white; box-shadow: 0 2px 8px rgba(124,58,237,0.3); }
.btn-primary:hover { opacity: 1; background: var(--green-mid); transform: translateY(-1px); }
.btn-outline  { background: white; color: var(--green); border: 1px solid var(--green); }
.btn-danger   { background: var(--red); color: white; }
.btn-amber    { background: var(--amber); color: white; }
.btn-sm { padding: 6px 13px; font-size: 13px; }

/* ── Status badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge-running         { background: #FEF3C7; color: #92400E; }
.badge-awaiting_review { background: #FFEDD5; color: #9A3412; }
.badge-completed       { background: var(--emerald-lt); color: #065F46; }
.badge-failed          { background: #FEE2E2; color: var(--red); }

/* ── Run table ────────────────────────────────────────────────────────────── */
.run-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.run-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 2px solid var(--border);
}
.run-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.run-table tr:last-child td { border-bottom: none; }
.run-table tr:hover td { background: var(--green-light); }
.run-table a { color: var(--green); text-decoration: none; font-weight: 500; }
.run-table a.btn-primary, .run-table a.btn-primary:hover, .run-table a.btn-primary:visited { color: white; text-decoration: none; }
.run-table a.btn-outline { color: var(--green); }
.run-table a:hover { text-decoration: underline; }
.brief-snippet { color: var(--muted); font-size: 13px; max-width: 380px;
                 white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Timeline ─────────────────────────────────────────────────────────────── */
.timeline { list-style: none; position: relative; padding-left: 0; }
.timeline::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline li {
  position: relative;
  padding: 6px 0 6px 44px;
  font-size: 14px;
}
.timeline .dot {
  position: absolute;
  left: 8px;
  top: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
}
.timeline .dot.done    { background: var(--emerald);  border-color: var(--emerald); }
.timeline .dot.active  { background: var(--green);    border-color: var(--green);
                         box-shadow: 0 0 0 3px rgba(124,58,237,0.2); }
.timeline .dot.failed  { background: var(--red);      border-color: var(--red); }
.timeline .dot.review  { background: #F97316;         border-color: #F97316; }
.stage-label { font-weight: 500; }
.stage-sub   { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ── Run detail layout ────────────────────────────────────────────────────── */
.run-layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
@media (max-width: 720px) { .run-layout { grid-template-columns: 1fr; } }

/* ── Review layout ────────────────────────────────────────────────────────── */
.review-layout { display: grid; grid-template-columns: 2fr 3fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .review-layout { grid-template-columns: 1fr; } }

.issue-list { list-style: none; font-size: 13px; }
.issue-list li {
  padding: 6px 10px;
  border-radius: 5px;
  margin-bottom: 5px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.issue-blocking   { background: #FEE2E2; }
.issue-warning    { background: #FEF3C7; }
.issue-suggestion { background: var(--green-light); }
.issue-icon { flex-shrink: 0; margin-top: 1px; }

.qa-score-ring {
  font-size: 42px;
  font-weight: 700;
  text-align: center;
  padding: 16px 0 8px;
}
.qa-score-ring.pass { color: var(--emerald); }
.qa-score-ring.fail { color: var(--red); }

/* ── Schedule / platform cards ────────────────────────────────────────────── */
.platform-grid { display: flex; flex-direction: column; gap: 16px; max-width: 820px; }

.platform-card { border: 1px solid var(--border); border-radius: var(--radius);
                 background: white; overflow: hidden; }
.platform-card .platform-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.platform-card .platform-body { padding: 14px 16px; }
.platform-header.facebook  { background: #E7F0FD; color: #1877F2; }
.platform-header.instagram { background: #FDF0F8; color: #C13584; }
.platform-header.linkedin  { background: #E8F4FB; color: #0A66C2; }

.platform-image-preview {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 5px;
  margin-bottom: 10px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--border);
}
.platform-image-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 5px; }

/* ── Misc helpers ─────────────────────────────────────────────────────────── */
.page-title { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 20px; }
.section-header { display: flex; align-items: center; justify-content: space-between;
                  margin-bottom: 16px; }
.text-muted  { color: var(--muted); font-size: 13px; }
.text-green  { color: var(--green); }
.mt-16 { margin-top: 16px; }
.mt-8  { margin-top: 8px; }
.gap-8 { display: flex; gap: 8px; flex-wrap: wrap; }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(124,58,237,0.2);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

details summary { cursor: pointer; font-weight: 600; font-size: 14px;
                  color: var(--green); padding: 6px 0; user-select: none; }
details summary:hover { opacity: 0.8; }
details[open] summary { margin-bottom: 14px; }

.url-fields { display: flex; flex-direction: column; gap: 8px; }

/* ── Mobile responsiveness ────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .page         { padding: 16px 12px 48px; }
  .card         { padding: 16px; }
  .page-title   { font-size: 18px; }
  .section-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .run-layout   { grid-template-columns: 1fr; }
  .platform-grid { grid-template-columns: 1fr; }
  .form-grid    { grid-template-columns: 1fr; }
  .btn          { font-size: 13px; padding: 8px 14px; }
  .run-table    { font-size: 13px; }
  .run-table th, .run-table td { padding: 8px 6px; }
  /* Hide less important columns on small screens */
  .run-table .col-hide-mobile { display: none; }
}


/* ── Beta Feedback Widget ────────────────────────────────────────────────── */
.beta-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 10px 16px 10px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(124,58,237,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.beta-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(124,58,237,0.45); }
.beta-fab-label { letter-spacing: 0.01em; }

.beta-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12,10,26,0.5);
  z-index: 1000;
}
.beta-overlay.open { display: block; }

.beta-panel {
  display: none;
  flex-direction: column;
  position: fixed;
  bottom: 80px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(12,10,26,0.25);
  z-index: 1001;
  overflow: hidden;
}
.beta-panel.open { display: flex; }

.beta-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.beta-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}
.beta-close:hover { color: #fff; }

.beta-panel-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.beta-meta {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.beta-meta-row { display: flex; gap: 8px; font-size: 12px; }
.beta-meta-label { color: var(--muted); min-width: 60px; flex-shrink: 0; }
.beta-meta-value { color: var(--text); font-weight: 500; word-break: break-all; }

.beta-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: -4px;
}
.beta-hint { font-weight: 400; color: var(--muted); }

.beta-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
}
.beta-input:focus { outline: none; border-color: var(--green); }

.beta-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
  min-height: 90px;
}
.beta-textarea:focus { outline: none; border-color: var(--green); }

.beta-radio-group { display: flex; gap: 14px; }
.beta-radio {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
}

.beta-error {
  background: #FEE2E2;
  color: #991B1B;
  border-radius: 5px;
  padding: 7px 10px;
  font-size: 12px;
}
.beta-success {
  background: #D1FAE5;
  color: #065F46;
  border-radius: 5px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 500;
}

.beta-panel-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: #fff;
}

/* Admin feedback table badges */
.badge-red  { background: #FEE2E2; color: #991B1B; }
.badge-blue { background: #DBEAFE; color: #1E40AF; }

@media (max-width: 600px) {
  .beta-panel { right: 8px; bottom: 72px; width: calc(100vw - 16px); }
  .beta-fab   { right: 12px; bottom: 16px; }
}

/* ── Phase pipeline UI ─────────────────────────────────────────────────────── */

/* Phase status badges (supplement existing .badge-* classes) */
.badge-generating  { background: #FEF3C7; color: #92400E; }
.badge-review      { background: #D1FAE5; color: #065F46; }
.badge-publishing  { background: #DBEAFE; color: #1E40AF; }
.badge-published   { background: #D1FAE5; color: #065F46; }
.badge-failed      { background: #FEE2E2; color: var(--red); }

/* Animated pulse dot for generating/publishing badges */
.badge-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  animation: pulseDot 1.4s ease-in-out infinite;
}
.badge-generating .badge-dot { background: #D97706; }
.badge-publishing  .badge-dot { background: #2563EB; }
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* Phase progress bar */
.phase-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px;
  margin-bottom: 20px;
}
.phase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.phase-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.phase-status-text {
  font-size: 14px;
  color: var(--muted);
  margin-top: 10px;
  margin-bottom: 8px;
}
.progress-track {
  width: 100%;
  height: 6px;
  background: #E5E7EB;
  border-radius: 9999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.6s ease;
}
.progress-fill.generating { background: #F59E0B; }
.progress-fill.publishing  { background: #3B82F6; }
.progress-pct {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  text-align: right;
}

/* Dashboard filter tabs */
.dash-filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
}
.dash-filter-tab {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 4px 4px 0 0;
  transition: color 0.15s, border-color 0.15s;
  text-decoration: none;
  display: inline-block;
}
.dash-filter-tab:hover { color: var(--text); }
.dash-filter-tab.active {
  color: var(--green);
  border-bottom-color: var(--green);
  font-weight: 600;
}
.dash-filter-tab .tab-count {
  display: inline-block;
  background: var(--green-light);
  color: var(--green);
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  margin-left: 5px;
  vertical-align: middle;
}
.dash-filter-tab.active .tab-count {
  background: var(--green);
  color: white;
}

/* Published summary card */
.publish-summary {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px;
}
.publish-summary-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}
.publish-summary-title a { color: var(--green); text-decoration: none; }
.publish-summary-title a:hover { text-decoration: underline; }
.publish-platforms {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.publish-platform-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
  background: var(--bg);
  transition: background 0.15s;
}
.publish-platform-link:hover { background: var(--green-light); }
.publish-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* GENERATION_FAILED state */
.phase-failed-card {
  background: #FFF7ED;
  border: 1px solid #FED7AA;
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
}
.phase-failed-title {
  font-size: 16px;
  font-weight: 700;
  color: #9A3412;
  margin-bottom: 8px;
}
.phase-failed-errors {
  list-style: none;
  margin-bottom: 16px;
}
.phase-failed-errors li {
  font-size: 13px;
  color: #7C2D12;
  padding: 4px 0;
}
.phase-failed-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Article review (inline, in run_detail) */
.review-article-wrapper {
  position: relative;
}
.review-article-body {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
}
.review-article-body h1,
.review-article-body h2,
.review-article-body h3 {
  margin-top: 1.4em;
  margin-bottom: 0.5em;
  font-weight: 700;
  color: var(--text);
}
.review-article-body p   { margin-bottom: 1em; }
.review-article-body ul,
.review-article-body ol  { margin-bottom: 1em; padding-left: 1.5em; }
.review-article-body li  { margin-bottom: 0.25em; }

/* Per-paragraph comment anchor */
.para-wrapper {
  position: relative;
  padding-right: 36px;
}
.para-comment-btn {
  position: absolute;
  right: 0;
  top: 2px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 2px 4px;
  border-radius: 4px;
}
.para-wrapper:hover .para-comment-btn { opacity: 1; }
.para-comment-btn.has-comments { opacity: 1; color: var(--green); }
.para-comment-count {
  font-size: 10px;
  font-weight: 700;
  vertical-align: super;
}

/* Comment thread panel (slides in from right side of article) */
.comment-thread {
  border-left: 3px solid var(--border);
  margin: 8px 0 8px 0;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 0 6px 6px 0;
  font-size: 13px;
}
.comment-thread.resolved { opacity: 0.6; }
.comment-item {
  margin-bottom: 10px;
}
.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.comment-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.comment-author { font-weight: 600; color: var(--text); font-size: 12px; }
.comment-time   { font-size: 11px; color: var(--muted); }
.comment-body   { color: var(--text); line-height: 1.5; }
.comment-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.comment-action-btn {
  background: none;
  border: none;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.comment-action-btn:hover { color: var(--green); }
.comment-replies { margin-left: 32px; border-left: 2px solid var(--border); padding-left: 10px; margin-top: 6px; }
.comment-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: flex-start;
}
.comment-input-row textarea {
  flex: 1;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  resize: none;
  font-family: inherit;
}
.comment-input-row textarea:focus { outline: none; border-color: var(--green); }

/* Review action buttons bar */
.review-actions-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  align-items: center;
}

/* Rejection modal */
.rejection-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
.rejection-modal-overlay.open { display: flex; }
.rejection-modal {
  background: white;
  border-radius: 12px;
  padding: 28px;
  max-width: 480px;
  width: 100%;
  margin: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}
.rejection-modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.rejection-modal p  { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.rejection-modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }

/* Unresolved comments confirmation modal */
.confirm-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
.confirm-modal-overlay.open { display: flex; }
.confirm-modal {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  margin: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}
.confirm-modal h3  { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.confirm-modal p   { color: var(--muted); font-size: 13px; margin-bottom: 0; }
.confirm-modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }

/* Citation inline styles */
.citation-ref {
  font-size: 0.72em;
  vertical-align: super;
  text-decoration: none;
  color: #6B7280;
  font-weight: 600;
}
.citation-ref--warning {
  color: #D97706;
}
.references-section {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 2px solid var(--border);
}
.references-section h2 { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.reference-item {
  font-size: 13px;
  margin-bottom: 10px;
  padding-left: 20px;
  position: relative;
}
.reference-item .ref-num {
  position: absolute;
  left: 0;
  color: var(--muted);
  font-weight: 600;
}
.reference-item .ref-warning { color: #D97706; }
.reference-item a { color: var(--muted); font-size: 12px; }

/* ── Client edit — left side-nav (brief §6) ──────────────────────────────── */
/* Layout: side-nav left, panels right. Falls back to a horizontal scroll bar on
   narrow viewports so the existing template structure works as-is. */
body:has(.ce-tabs) .page { max-width: 1280px; }
.ce-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-raised);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  position: sticky;
  top: calc(var(--nav-height) + var(--space-3));
  align-self: start;
  width: 220px;
  flex-shrink: 0;
  font-family: var(--font-sans);
}
.ce-tab {
  background: none;
  border: none;
  border-left: 3px solid transparent;
  padding: 9px 12px 9px 14px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: color var(--motion-fast), background var(--motion-fast);
  text-align: left;
  font-family: inherit;
}
.ce-tab:hover { color: var(--text-primary); background: var(--accent-soft-bg); }
.ce-tab.ce-tab-active {
  color: var(--accent-stronger);
  background: var(--accent-soft-bg);
  border-left-color: var(--accent-strong);
  font-weight: var(--weight-semibold);
}
.ce-tab:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Wrap tabs + panels in a flex row. Existing template doesn't have a wrapper,
   so we use the .page > .ce-tabs adjacency to lay it out as a 2-column grid. */
.page:has(> .ce-tabs) {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}
.page:has(> .ce-tabs) > :not(.ce-tabs):not(.section-header):not(.flash) {
  grid-column: 2;
}
.page:has(> .ce-tabs) > .section-header,
.page:has(> .ce-tabs) > .flash { grid-column: 1 / -1; }

@media (max-width: 900px) {
  .ce-tabs {
    flex-direction: row;
    overflow-x: auto;
    width: auto;
    position: static;
    padding: var(--space-1);
    gap: var(--space-1);
  }
  .ce-tab {
    border-left: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    padding: 8px 14px;
  }
  .ce-tab.ce-tab-active {
    border-left: none;
    border-bottom-color: var(--accent-strong);
  }
  .page:has(> .ce-tabs) {
    display: block;
  }
  .page:has(> .ce-tabs) > :not(.ce-tabs):not(.section-header):not(.flash) {
    grid-column: auto;
  }
}

/* ── @mention autocomplete dropdown ────────────────────────────────────────── */
.mention-dropdown {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  max-height: 200px;
  overflow-y: auto;
}
.mention-item {
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.mention-item:hover,
.mention-item.mention-active {
  background: var(--green);
  color: #fff;
}

/* ── Two-column article review layout ──────────────────────────────────────── */
.review-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
  align-items: start;
}
.review-sidebar {
  position: sticky;
  top: 70px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  /* hide scrollbar while keeping scroll */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.review-sidebar-heading {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0 2px 8px;
}

/* Per-paragraph note box (right sidebar) */
.para-note-box {
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 8px 10px;
  margin-bottom: 6px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  font-size: 12px;
}
.para-note-box.active {
  border-color: var(--green);
  background: #f0fdf4;
  box-shadow: 0 0 0 2px rgba(16,185,129,.12);
}
.para-note-box.has-content {
  border-color: #7c3aed;
  background: #f5f3ff;
}
.para-note-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.para-note-box textarea {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 12px;
  resize: none;
  font-family: inherit;
  color: var(--text);
  outline: none;
  min-height: 28px;
  display: block;
}
.para-note-existing {
  margin-top: 6px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
.para-note-comment {
  font-size: 11px;
  color: var(--text);
  line-height: 1.4;
  padding: 3px 0;
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.para-note-comment-author {
  font-weight: 600;
  color: var(--muted);
  flex-shrink: 0;
}
.para-note-post-btn {
  margin-top: 4px;
  font-size: 11px;
  padding: 2px 8px;
  display: none;
}
.para-note-box.typing .para-note-post-btn { display: inline-block; }

/* Paragraph hover/focus highlight (left column) */
.annotatable-para {
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.12s;
  padding: 2px 6px;
  margin: 0 -6px;
}
.annotatable-para:hover { background: rgba(124,58,237,.06); }
.annotatable-para.para-focused {
  background: rgba(124,58,237,.10);
  outline: 1.5px solid rgba(124,58,237,.25);
  outline-offset: 1px;
}

/* Article-level note at bottom of sidebar */
.sidebar-article-note {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.sidebar-article-note label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 6px;
}
.sidebar-article-note textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
  font-size: 12px;
  font-family: inherit;
  padding: 5px 7px;
  resize: vertical;
  outline: none;
}
.sidebar-article-note textarea:focus { border-color: var(--green); }

/* ── Published summary page ─────────────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.summary-stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.summary-stat-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.summary-stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.social-preview-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}
.social-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.social-preview-body {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 12px;
  padding: 12px 14px;
}
.social-preview-img {
  width: 100px;
  height: 66px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.social-preview-text {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  max-height: 80px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
.social-preview-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}
.download-banner {
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  border-radius: 10px;
  padding: 24px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.download-banner h2 { color: white; margin: 0 0 4px; font-size: 18px; }
.download-banner p  { color: rgba(255,255,255,.8); margin: 0; font-size: 13px; }
.download-banner .btn-download {
  background: white;
  color: #7c3aed;
  padding: 10px 22px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  flex-shrink: 0;
}

/* ── AI Assistant widget ───────────────────────────────────────────────────── */

.ai-fab {
  position: fixed;
  bottom: 76px;
  right: 24px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 10px 16px 10px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(124,58,237,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.ai-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(124,58,237,0.45); }
.ai-fab svg { flex-shrink: 0; }

.ai-panel {
  display: none;
  flex-direction: column;
  position: fixed;
  bottom: 80px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 48px rgba(12,10,26,0.28);
  z-index: 1001;
  overflow: hidden;
}
.ai-panel.open { display: flex; }

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: linear-gradient(135deg, #7C3AED, #10B981);
  color: #fff;
  flex-shrink: 0;
}
.ai-panel-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
}
.ai-panel-header-left span.ai-model-badge {
  font-size: 10px;
  font-weight: 500;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 2px 7px;
  letter-spacing: 0.03em;
}
.ai-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}
.ai-close:hover { color: #fff; }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 90%;
}
.ai-msg.user  { align-self: flex-end; align-items: flex-end; }
.ai-msg.asst  { align-self: flex-start; align-items: flex-start; }

.ai-bubble {
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.ai-msg.user .ai-bubble {
  background: var(--green);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg.asst .ai-bubble {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ai-typing {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 9px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.ai-typing span {
  width: 6px; height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: ai-bounce 1.2s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.ai-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: #fff;
}
.ai-input {
  flex: 1;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.45;
  overflow-y: auto;
}
.ai-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(124,58,237,0.12); }
.ai-send {
  flex-shrink: 0;
  width: 36px; height: 36px;
  background: var(--green);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.ai-send:hover { background: var(--green-mid); }
.ai-send:disabled { opacity: 0.45; cursor: default; }

@media (max-width: 600px) {
  .ai-panel { right: 8px; bottom: 72px; width: calc(100vw - 16px); }
  .ai-fab   { right: 12px; bottom: 68px; }
}

/* STEP 4: user avatar dropdown */
.user-menu { position: relative; margin-left: 8px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--green); color: white; font-weight: 600; font-size: 13px;
  border: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.user-avatar:hover { filter: brightness(1.1); }
.user-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 200px; background: white; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 1000; overflow: hidden;
}
.user-menu.open .user-dropdown { display: block; }
.user-dd-header { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.user-dd-email { font-size: 12px; color: var(--text); font-weight: 500; word-break: break-all; }
.user-dd-role { font-size: 10.5px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }
nav .user-dd-item,
nav a.user-dd-item,
nav button.user-dd-item {
  display: block; width: 100%; text-align: left; padding: 9px 14px;
  font-size: 13px; color: var(--text) !important; text-decoration: none;
  background: white; border: none; cursor: pointer; font-family: inherit;
  line-height: 1.3;
}
nav .user-dd-item:hover,
nav a.user-dd-item:hover { background: var(--emerald-lt); color: var(--text) !important; }
nav .user-dd-signout,
nav button.user-dd-signout { border-top: 1px solid var(--border); color: #b91c1c !important; }
nav .user-dd-signout:hover { background: #fef2f2; color: #b91c1c !important; }

/* STEP 5: New Article slide-out panel */
.slide-panel-backdrop {
  position: fixed; inset: 0; background: rgba(12,10,26,0.45);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
  z-index: 9000;
}
.slide-panel-backdrop.open { opacity: 1; pointer-events: auto; }

.slide-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(640px, 100vw);
  background: white;
  box-shadow: -12px 0 36px rgba(0,0,0,0.18);
  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 9001;
  overflow-y: auto;
  padding: 20px;
}
.slide-panel.open { transform: translateX(0); }
.slide-panel > .card { box-shadow: none; border: none; padding: 0; }

.slide-panel-close {
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--muted); padding: 4px 10px;
  border-radius: 6px; line-height: 1;
}
.slide-panel-close:hover { background: var(--bg); color: var(--text); }

@media (max-width: 640px) {
  .slide-panel { width: 100vw; padding: 14px; }
}


/* Status colors */
.cal-status-draft      { border-left-color: #9ca3af; background: #f3f4f6; }
.cal-status-scheduled  { border-left-color: #f59e0b; background: #fffbeb; }
.cal-status-generating { border-left-color: #2563eb; background: #eff6ff; }
.cal-status-review     { border-left-color: #10b981; background: #ecfdf5; }
.cal-status-review .cal-article-badge::before { content: '● '; color: #10b981; }
.cal-status-published  { border-left-color: #059669; background: #d1fae5; color: #064e3b; }
.cal-status-published .cal-article-badge::before { content: '✓ '; }
.cal-status-issue      { border-left-color: #dc2626; background: #fef2f2; color: #7f1d1d; }

/* Upcoming list */
.cal-upcoming { display: flex; flex-direction: column; gap: 6px; }
.cal-upcoming-row {
  display: grid; grid-template-columns: 12px 70px 1fr auto; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-left-width: 3px;
  border-radius: 6px; text-decoration: none; color: var(--text); font-size: 13px;
  background: white;
}
.cal-upcoming-row:hover { background: var(--bg); }
.cal-upcoming-row.cal-status-draft      { border-left-color: #9ca3af; }
.cal-upcoming-row.cal-status-scheduled  { border-left-color: #f59e0b; }
.cal-upcoming-row.cal-status-generating { border-left-color: #2563eb; }
.cal-upcoming-row.cal-status-review     { border-left-color: #10b981; }
.cal-upcoming-row.cal-status-published  { border-left-color: #059669; }
.cal-upcoming-row.cal-status-issue      { border-left-color: #dc2626; }
.cal-upcoming-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.55; }
.cal-upcoming-date { font-weight: 600; color: var(--muted); font-size: 12px; }
.cal-upcoming-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-upcoming-status {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--muted);
}

@media (max-width: 700px) {
  .cal-day { height: 88px; padding: 3px; }
  .cal-article { font-size: 10px; padding: 2px 4px; }
  .cal-upcoming-row { grid-template-columns: 10px 54px 1fr; }
  .cal-upcoming-row .cal-upcoming-status { display: none; }
}


/* Calendar (server-rendered) */
.cal-header { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:14px; flex-wrap:wrap; }
.cal-nav { display:flex; align-items:center; gap:8px; }
.cal-nav-btn { width:28px; height:28px; display:inline-flex; align-items:center; justify-content:center;
  background:var(--bg); border:1px solid #e5e7eb; border-radius:6px; color:var(--text); text-decoration:none; font-size:12px; }
.cal-nav-btn:hover { background:#e5e7eb; }
.cal-month-label { font-size:16px; font-weight:600; min-width:160px; text-align:center; }
.cal-today-btn { margin-left:4px; background:white; border:1px solid #e5e7eb; border-radius:6px;
  padding:5px 12px; font-size:12px; color:var(--text); text-decoration:none; }
.cal-today-btn:hover { background:var(--bg); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #e5e7eb;
  gap: 1px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}
.cal-dow {
  background: #f9fafb; padding: 8px 10px;
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.cal-cell {
  background: white; min-height: 110px; padding: 6px 8px; cursor: pointer;
  transition: background .1s;
}
.cal-cell:hover { background: #fafafa; }
.cal-cell-other { background: #f7f7f9; }
.cal-cell-past { background: #f3f4f6; color: var(--muted); }
.cal-cell-past .cal-cell-num { color: #9ca3af; }
.cal-cell-past:hover { background: #ececef; }
.cal-cell-other .cal-cell-num { color: var(--muted); }
.cal-cell-today { background: #ecfdf5; }
.cal-cell-today .cal-cell-num {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--green); color: white; width: 24px; height: 24px; border-radius: 50%; font-weight: 700;
}
.cal-cell-num { font-size: 13px; font-weight: 500; }

@media (max-width: 700px) {
  .cal-cell { min-height: 74px; padding: 4px 5px; }
  /* beta_feedback #142: bigger touch targets + visible swipe affordance */
  .cal-nav-btn { width: 44px; height: 44px; font-size: 18px; }
  .cal-today-btn { padding: 10px 16px; font-size: 14px; }
  .cal-month-label { font-size: 17px; min-width: 0; }
  .cal-grid { touch-action: pan-y; }
  .cal-swipe-hint {
    display: block;
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    margin-top: 8px;
  }
}
.cal-swipe-hint { display: none; }

/* Trending topic cards — Fresh angles / Hot right now */
.trend-section { margin-top: 12px; }
.trend-section:first-child { margin-top: 0; }
.trend-section-label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.trend-list { display: flex; flex-wrap: wrap; gap: 8px; }
.trend-card {
  position: relative; display: flex; align-items: stretch;
  border: 1.5px solid var(--border); border-radius: 10px; background: #fff;
  max-width: 340px; transition: border-color .15s, background .15s, opacity .22s, transform .22s;
}
.trend-card:hover { border-color: var(--green); background: var(--green-light, #f0fdf4); }
.trend-card-body {
  flex: 1; text-align: left; padding: 8px 26px 8px 12px;
  background: transparent; border: 0; cursor: pointer;
  font-size: 12px; line-height: 1.4; color: var(--text); white-space: normal;
}
.trend-card-x {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
  border: 0; background: transparent; color: var(--muted); font-size: 12px;
  cursor: pointer; border-radius: 50%; line-height: 1; padding: 0;
}
.trend-card-x:hover { background: #fee2e2; color: #b91c1c; }
.trend-card-fading { opacity: 0; transform: scale(0.96); pointer-events: none; }
.trend-card-entering { opacity: 0; transform: translateY(-4px); }

/* ── Top-left client logo (feedback #42) ── */
.logo-client {
  width: auto;
  max-width: 80px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 3px;
  background: rgba(255,255,255,0.05);
}
.logo-client-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* ── Right-side PostNimble mini-brand + date (feedback #42) ── */
.nav-brand-date {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 8px;
  background: rgba(124,58,237,0.10);
  border: 1px solid rgba(124,58,237,0.22);
  border-radius: 8px;
  margin-right: 10px;
}
.nav-brand-mark {
  width: 18px;
  height: auto;
  opacity: 0.9;
  flex-shrink: 0;
}
.nav-date {
  color: rgba(255,255,255,0.78);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
@media (max-width: 720px) {
  .nav-brand-date { display: none; }
}

/* ──────────────────────────────────────────────────────────────────────────
 * §3 — Components (canonical primitives, brief §5.2)
 *
 * These rules complement / override the legacy component blocks above.
 * Selectors here use BEM-ish naming on top of existing class names so
 * templates don't need to change yet. As the page-by-page pass migrates
 * markup, legacy duplicates above will be retired in §9.5 (final refactor).
 *
 *   3.1  Focus rings (global)
 *   3.2  Buttons — variants, sizes, states
 *   3.3  Form fields — checkbox, radio, toggle, search, file, helper, error
 *   3.4  Status pills — canonical token mapping
 *   3.5  Modal (generic)
 *   3.6  Toasts
 *   3.7  Empty state
 *   3.8  Avatar
 *   3.9  Tables — sticky header, sortable, row-actions, tabular numerals
 *   3.10 Tabs (canonical)
 *   3.11 Card variants
 *   3.12 Mention chip
 *   3.13 Slide-out alignment
 *   3.14 Badge — neutral default + sizes
 * ──────────────────────────────────────────────────────────────────────── */

/* 3.1 Focus rings — global :focus-visible */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
}

/* 3.2 Buttons */
.btn { font-family: var(--font-sans); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-secondary {
  background: var(--surface-raised);
  color: var(--accent-strong);
  border: 1px solid var(--accent-strong);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--motion-fast) var(--easing-standard);
}
.btn-secondary:hover { background: var(--accent-soft-bg); }
.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--motion-fast) var(--easing-standard);
}
.btn-ghost:hover { background: var(--color-ink-100); }
.btn-destructive { background: var(--color-red-500); color: var(--text-on-accent); }
.btn-destructive:hover { background: var(--color-red-700); opacity: 1; }
.btn-lg {
  padding: 12px 24px;
  font-size: var(--text-md);
  border-radius: var(--radius-lg);
}
.btn--icon {
  padding: 8px;
  width: 36px;
  height: 36px;
  justify-content: center;
}
.btn-sm.btn--icon { width: 30px; height: 30px; padding: 5px; }
.btn-lg.btn--icon { width: 42px; height: 42px; padding: 10px; }
.btn--loading {
  pointer-events: none;
  position: relative;
  color: transparent !important;
}
.btn--loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid var(--text-on-accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: var(--motion-spin);
}
.btn-secondary.btn--loading::after,
.btn-ghost.btn--loading::after { border-color: var(--accent-strong); border-top-color: transparent; }

/* 3.3 Form fields */
input[type="date"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface-raised);
  transition: border-color var(--motion-fast) var(--easing-standard);
}
input:disabled,
textarea:disabled,
select:disabled {
  background: var(--color-ink-100);
  color: var(--text-disabled);
  cursor: not-allowed;
}

.form-field { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-3); }
.form-field__label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-secondary); }
.form-field__hint  { font-size: var(--text-xs); color: var(--text-tertiary); }
.form-field__error { font-size: var(--text-xs); color: var(--color-red-700); }
.form-field--invalid input,
.form-field--invalid textarea,
.form-field--invalid select { border-color: var(--color-red-500); }
.form-field--invalid input:focus,
.form-field--invalid textarea:focus,
.form-field--invalid select:focus {
  border-color: var(--color-red-500);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.20);
}

/* Custom checkbox & radio */
.checkbox,
.radio {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}
.checkbox > input[type="checkbox"],
.radio > input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-default);
  background: var(--surface-raised);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  transition: background var(--motion-fast), border-color var(--motion-fast);
  flex-shrink: 0;
  margin: 0;
}
.checkbox > input[type="checkbox"] { border-radius: var(--radius-sm); }
.radio > input[type="radio"] { border-radius: var(--radius-pill); }
.checkbox > input[type="checkbox"]:checked,
.radio > input[type="radio"]:checked {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
.checkbox > input[type="checkbox"]:checked::before {
  content: "";
  width: 11px;
  height: 11px;
  background: var(--text-on-accent);
  clip-path: polygon(14% 50%, 0 64%, 36% 100%, 100% 22%, 86% 8%, 36% 60%);
}
.radio > input[type="radio"]:checked::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--text-on-accent);
  border-radius: var(--radius-pill);
}
.checkbox > input[type="checkbox"]:focus-visible,
.radio    > input[type="radio"]:focus-visible {
  box-shadow: var(--focus-ring);
  outline: none;
}
.checkbox > input[type="checkbox"]:disabled,
.radio    > input[type="radio"]:disabled {
  background: var(--color-ink-100);
  cursor: not-allowed;
}

/* Toggle switch */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.toggle > input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  border-radius: var(--radius-pill);
  background: var(--color-ink-300);
  position: relative;
  cursor: pointer;
  transition: background var(--motion-fast) var(--easing-standard);
  flex-shrink: 0;
  margin: 0;
}
.toggle > input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  transition: transform var(--motion-fast) var(--easing-standard);
  box-shadow: 0 1px 2px rgba(11, 11, 15, 0.20);
}
.toggle > input[type="checkbox"]:checked { background: var(--accent-strong); }
.toggle > input[type="checkbox"]:checked::before { transform: translateX(16px); }
.toggle > input[type="checkbox"]:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.toggle > input[type="checkbox"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* Search input with leading icon */
.search { position: relative; display: inline-flex; align-items: center; width: 100%; }
.search__icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  width: 16px;
  height: 16px;
}
.search > input { padding-left: 34px !important; }

/* File upload */
.file-upload {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  position: relative;
}
.file-upload > input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.file-upload__btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 14px;
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--motion-fast), color var(--motion-fast);
}
.file-upload:hover .file-upload__btn,
.file-upload > input:focus-visible + .file-upload__btn {
  border-color: var(--accent-strong);
  color: var(--accent-strong);
}
.file-upload__name { font-size: var(--text-sm); color: var(--text-secondary); }

/* 3.4 Status pills — canonical token mapping (overrides legacy hex) */
.badge-generating,
.badge-running {
  background: var(--status-generating-bg);
  color: var(--status-generating-text);
}
.badge-review,
.badge-awaiting_review {
  background: var(--status-review-bg);
  color: var(--status-review-text);
}
.badge-scheduled {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  background: var(--status-scheduled-bg);
  color: var(--status-scheduled-text);
}
.badge-publishing { background: var(--status-publishing-bg); color: var(--status-publishing-text); }
.badge-published,
.badge-completed  { background: var(--status-published-bg);  color: var(--status-published-text); }
.badge-failed     { background: var(--status-failed-bg);     color: var(--status-failed-text); }
.badge-generating .badge-dot,
.badge-running    .badge-dot { background: var(--color-amber-500); }
.badge-publishing .badge-dot { background: var(--color-blue-500); }

/* 3.5 Generic modal */
.modal__overlay {
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  z-index: var(--z-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
.modal__overlay.open { display: flex; }
.modal {
  background: var(--surface-raised);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 480px;
  width: 100%;
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
}
.modal__header {
  padding: var(--space-5) var(--space-6) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}
.modal__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}
.modal__body { padding: var(--space-5) var(--space-6); overflow-y: auto; flex: 1; }
.modal__footer {
  position: sticky;
  bottom: 0;
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-raised);
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* 3.6 Toasts */
.toast-stack {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--surface-chrome);
  color: var(--text-on-chrome);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 240px;
  max-width: 360px;
  animation: toast-in var(--motion-base) var(--easing-decelerate);
}
.toast--success { background: var(--color-green-700); }
.toast--warning { background: var(--color-amber-700); }
.toast--error   { background: var(--color-red-700); }
.toast__close {
  background: none;
  border: none;
  color: var(--text-on-chrome-dim);
  cursor: pointer;
  margin-left: auto;
  padding: 0 var(--space-1);
  font-size: var(--text-md);
}
.toast__close:hover { color: var(--text-on-chrome); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (max-width: 600px) {
  .toast-stack { left: var(--space-3); right: var(--space-3); bottom: var(--space-3); }
  .toast { min-width: 0; max-width: none; width: 100%; }
}

/* 3.7 Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-12) var(--space-6);
  gap: var(--space-3);
}
.empty-state__art {
  width: 96px;
  height: 96px;
  color: var(--color-ink-300);
  margin-bottom: var(--space-2);
}
.empty-state__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}
.empty-state__subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 360px;
  line-height: var(--leading-normal);
}
.empty-state__actions { margin-top: var(--space-3); display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; }

/* 3.8 Avatar */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--accent-strong);
  color: var(--text-on-accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  font-family: var(--font-sans);
  text-transform: uppercase;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar--lg { width: 40px; height: 40px; font-size: var(--text-sm); }
.avatar--xl { width: 56px; height: 56px; font-size: var(--text-md); }

/* 3.9 Tables — sticky header, sortable, row actions, tabular numerals */
.run-table th[aria-sort],
.table     th[aria-sort] {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 18px;
}
.run-table th[aria-sort]::after,
.table     th[aria-sort]::after {
  content: "↕";
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 10px;
  opacity: 0.6;
}
.run-table th[aria-sort="ascending"]::after,
.table     th[aria-sort="ascending"]::after {
  content: "↑";
  opacity: 1;
  color: var(--accent-strong);
}
.run-table th[aria-sort="descending"]::after,
.table     th[aria-sort="descending"]::after {
  content: "↓";
  opacity: 1;
  color: var(--accent-strong);
}
.run-table--sticky thead th,
.table--sticky    thead th {
  position: sticky;
  top: 0;
  background: var(--surface-canvas);
  z-index: 1;
}
.run-table td,
.table     td,
.metric-num,
.num-tabular {
  font-variant-numeric: tabular-nums lining-nums;
}

/* Row actions menu (popover anchored to a row) */
.row-actions { position: relative; display: inline-flex; }
.row-actions__trigger {
  background: none;
  border: none;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.row-actions__trigger:hover { background: var(--color-ink-100); color: var(--text-primary); }
.row-actions__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: var(--z-popover);
  display: none;
  padding: var(--space-1) 0;
}
.row-actions.open .row-actions__menu { display: block; }
.row-actions__item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.row-actions__item:hover { background: var(--accent-soft-bg); color: var(--accent-soft-text); }
.row-actions__item--danger { color: var(--color-red-700); }
.row-actions__item--danger:hover { background: var(--color-red-50); color: var(--color-red-700); }

/* 3.10 Tabs (canonical) */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border-subtle);
  flex-wrap: wrap;
}
.tabs__tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 9px 16px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  transition: color var(--motion-fast), background var(--motion-fast);
  text-decoration: none;
  display: inline-block;
  font-family: inherit;
}
.tabs__tab:hover { color: var(--text-primary); background: var(--surface-canvas); }
.tabs__tab[aria-selected="true"],
.tabs__tab.is-active {
  color: var(--accent-strong);
  border-bottom-color: var(--accent-strong);
  font-weight: var(--weight-semibold);
}
@media (max-width: 600px) {
  .tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .tabs__tab { flex: 1 0 auto; min-width: max-content; text-align: center; }
}

/* 3.11 Card variants */
.card--interactive {
  transition: transform var(--motion-fast) var(--easing-standard),
              box-shadow var(--motion-fast) var(--easing-standard);
  cursor: pointer;
}
.card--interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card--sm { padding: var(--space-3); }
.card--lg { padding: var(--space-8); }

/* 3.12 Mention chip */
.mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft-bg);
  color: var(--accent-soft-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.mention-chip::before { content: "@"; opacity: 0.7; }

/* Comment thread — limit nested replies to one level (brief §5.2) */
.comment-replies .comment-replies { display: none; }

/* 3.13 Slide-out alignment — brief §5.2: ~480px desktop, full-screen mobile */
.slide-panel {
  width: var(--slide-out-width);
  max-width: 100vw;
}
@media (max-width: 720px) {
  .slide-panel { width: 100vw; }
}

/* 3.14 Badge — neutral default + sizes */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  background: var(--color-ink-100);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums lining-nums;
}
.badge--sm { padding: 1px 7px; font-size: 10.5px; }
.badge--accent { background: var(--accent-soft-bg); color: var(--accent-soft-text); }
.badge--neutral { background: var(--color-ink-100); color: var(--text-secondary); }

/* ──────────────────────────────────────────────────────────────────────────
 * §4 — Page-specific
 *   4.1 Auth shell (login, forgot, reset, accept-terms, accept-platform)
 * ──────────────────────────────────────────────────────────────────────── */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-4);
  background: var(--surface-canvas);
  position: relative;
}
.auth-shell::before {
  content: "";
  position: fixed;
  inset: -10% 0 auto 0;
  height: 60vh;
  background: radial-gradient(ellipse at 50% 0%,
    rgba(196, 181, 253, 0.20) 0%,
    rgba(196, 181, 253, 0) 60%);
  pointer-events: none;
  z-index: 0;
}
.auth-shell__inner {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}
.auth-shell__brand {
  text-align: center;
  margin-bottom: var(--space-6);
}
.auth-shell__brand-mark {
  width: 56px;
  height: auto;
  display: block;
  margin: 0 auto var(--space-3);
}
.auth-shell__wordmark {
  font-family: var(--font-sans);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}
.auth-shell__sub {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-top: var(--space-1);
}
.auth-shell__card {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: var(--space-8) var(--space-6);
}
.auth-shell__title {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.auth-shell__intro {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-5);
}
.auth-shell__row { margin-bottom: var(--space-4); }
.auth-shell__row > label {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-1);
}
.auth-shell__submit {
  width: 100%;
  margin-top: var(--space-3);
  padding: 12px;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  justify-content: center;
}
.auth-shell__remember {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--space-3) 0 var(--space-2);
  font-size: var(--text-sm);
}
.auth-shell__footer {
  text-align: center;
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.auth-shell__footer a {
  color: var(--text-link);
  text-decoration: none;
  font-weight: var(--weight-medium);
}
.auth-shell__footer a:hover { text-decoration: underline; }
.auth-shell__back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
}
.auth-shell__back:hover { color: var(--text-primary); }

/* Password strength meter */
.auth-shell__strength {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--color-ink-200);
  overflow: hidden;
  margin-top: var(--space-1);
}
.auth-shell__strength-bar {
  height: 100%;
  width: 0%;
  background: var(--color-red-500);
  transition: width var(--motion-base), background-color var(--motion-base);
}
.auth-shell__strength-label {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
.is-strength-weak   .auth-shell__strength-bar { width: 33%; background: var(--color-red-500); }
.is-strength-medium .auth-shell__strength-bar { width: 66%; background: var(--color-amber-500); }
.is-strength-strong .auth-shell__strength-bar { width: 100%; background: var(--color-green-500); }
.is-strength-weak   .auth-shell__strength-label { color: var(--color-red-700); }
.is-strength-medium .auth-shell__strength-label { color: var(--color-amber-700); }
.is-strength-strong .auth-shell__strength-label { color: var(--color-green-700); }

/* Auth-shell flash messages — slimmer than the in-app .flash */
.auth-shell .flash {
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  border: 1px solid transparent;
}
.auth-shell .flash.error   { background: var(--feedback-error-bg);   color: var(--feedback-error-text);   border-color: rgba(220,38,38,0.2); }
.auth-shell .flash.info    { background: var(--feedback-info-bg);    color: var(--feedback-info-text); }
.auth-shell .flash.success { background: var(--feedback-success-bg); color: var(--feedback-success-text); }
.auth-shell .flash.warning { background: var(--feedback-warning-bg); color: var(--feedback-warning-text); }

/* Auth shell — wide variant (terms, platform disclaimer) */
.auth-shell--wide .auth-shell__inner { max-width: 680px; }
.auth-shell--wide { align-items: flex-start; padding-top: var(--space-12); }

/* Scrollable body inside an auth card (used by terms & platform disclaimer) */
.auth-shell__scroll-body {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  background: var(--surface-canvas);
  margin-bottom: var(--space-5);
}
.auth-shell__scroll-body h3 { font-size: var(--text-sm); font-weight: var(--weight-semibold); margin: var(--space-4) 0 var(--space-2); }
.auth-shell__scroll-body h3:first-child { margin-top: 0; }
.auth-shell__scroll-body p,
.auth-shell__scroll-body li { margin-bottom: var(--space-2); }
.auth-shell__scroll-body ul { padding-left: var(--space-5); }

/* Acknowledge row (checkbox above CTA) */
.auth-shell__ack {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--text-primary);
}
.auth-shell__ack > input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-default);
  background: var(--surface-raised);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
}
.auth-shell__ack > input[type="checkbox"]:checked {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
.auth-shell__ack > input[type="checkbox"]:checked::before {
  content: "";
  width: 11px;
  height: 11px;
  background: var(--text-on-accent);
  clip-path: polygon(14% 50%, 0 64%, 36% 100%, 100% 22%, 86% 8%, 36% 60%);
}
.auth-shell__ack > input[type="checkbox"]:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Glyph used by error pages (replaces the old emoji) */
.auth-shell__glyph {
  width: 88px;
  height: 88px;
  display: block;
  margin: 0 auto var(--space-4);
  color: var(--accent-strong);
  opacity: 0.85;
}

/* Scroll-body affordances inside auth-shell (links inside terms text) */
.auth-shell__scroll-body a { color: var(--text-link); }
.auth-shell__scroll-body a:hover { text-decoration: underline; }

/* Action row at bottom of an auth card */
.auth-shell__actions { display: flex; gap: var(--space-2); }
.auth-shell__actions .btn { flex: 1; justify-content: center; }

/* ──────────────────────────────────────────────────────────────────────────
 * §4.2 — Marketing landing (public homepage)
 * ──────────────────────────────────────────────────────────────────────── */

/* Reset for marketing pages — they bypass .page wrapper and have their own
   sectional rhythm. Body-level reset covers smooth scrolling. */
html { scroll-behavior: smooth; }

/* Hero */
.market-hero {
  background: var(--surface-chrome);
  color: var(--text-on-chrome);
  padding: var(--space-16) var(--space-6) var(--space-12);
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.market-hero::before {
  content: "";
  position: absolute;
  top: -160px; left: 50%;
  transform: translateX(-50%);
  width: 900px; height: 700px;
  background: radial-gradient(ellipse at center, rgba(196, 181, 253, 0.20) 0%, transparent 70%);
  pointer-events: none;
}
.market-hero__inner { position: relative; z-index: 1; max-width: 760px; }

.market-hero__brand {
  margin-bottom: var(--space-8);
}
.market-hero__brand img {
  width: min(82vw, 560px);
  height: auto;
}

.market-hero__title {
  font-family: var(--font-sans);
  font-size: clamp(28px, 4vw, 48px);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-on-chrome);
  margin-bottom: var(--space-4);
}
.market-hero__title-accent {
  color: var(--accent);
}
.market-hero__sub {
  font-family: var(--font-sans);
  font-size: clamp(15px, 1.6vw, 18px);
  color: var(--text-on-chrome-dim);
  max-width: 560px;
  margin: 0 auto var(--space-8);
  line-height: var(--leading-normal);
}

.market-hero__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
}

/* Marketing-specific button overrides for the dark hero context */
.market-hero .btn-primary {
  padding: 14px 28px;
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}
.market-hero .btn-ghost-on-dark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-on-chrome-dim);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  padding: 14px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: background var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast);
}
.market-hero .btn-ghost-on-dark:hover {
  color: var(--text-on-chrome);
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.04);
}

/* Pipeline visual */
.market-pipeline {
  margin-top: var(--space-12);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-1);
  position: relative;
  z-index: 1;
}
.market-pipeline__step {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-on-chrome-dim);
}
.market-pipeline__dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  box-shadow: 0 0 6px rgba(196, 181, 253, 0.7);
  flex-shrink: 0;
}
.market-pipeline__arrow {
  color: rgba(255, 255, 255, 0.18);
  font-size: var(--text-md);
  padding: 0 var(--space-1);
  align-self: center;
}
@media (max-width: 720px) {
  .market-pipeline { display: none; }
}

/* Social proof strip */
.market-strip {
  background: #07050F;
  padding: var(--space-6) var(--space-6);
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-on-chrome-dim);
}
.market-strip__label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.36);
  margin-bottom: var(--space-4);
}
.market-strip__row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  flex-wrap: wrap;
}
.market-strip__pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: rgba(255, 255, 255, 0.5);
}
.market-strip__pill img,
.market-strip__pill svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Generic marketing section + section heading */
.market-section {
  padding: var(--space-16) var(--space-6);
}
.market-section--alt   { background: var(--surface-canvas); }
.market-section--white { background: var(--surface-raised); }
.market-section--dark  { background: var(--surface-chrome); color: var(--text-on-chrome); }

.market-section__inner { max-width: 1100px; margin: 0 auto; }
.market-section__label {
  text-align: center;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: var(--space-3);
}
.market-section__title {
  text-align: center;
  font-family: var(--font-sans);
  font-size: clamp(24px, 3.4vw, 36px);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  line-height: var(--leading-tight);
}
.market-section--dark .market-section__title { color: var(--text-on-chrome); }
.market-section__sub {
  text-align: center;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto var(--space-12);
  line-height: var(--leading-normal);
}
.market-section--dark .market-section__sub { color: var(--text-on-chrome-dim); }

/* Feature grid */
.market-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-5);
}
.market-feature {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  transition: transform var(--motion-fast) var(--easing-standard),
              box-shadow var(--motion-fast) var(--easing-standard);
}
.market-feature:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.market-feature__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  background: var(--accent-soft-bg);
  color: var(--accent-soft-text);
}
.market-feature__icon svg { width: 22px; height: 22px; }
.market-feature h3 {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  letter-spacing: var(--tracking-tight);
}
.market-feature p {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
}

/* Steps */
.market-steps {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
.market-step {
  display: flex;
  gap: var(--space-6);
  align-items: flex-start;
  padding: var(--space-6) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.market-step:last-child { border-bottom: none; }
.market-step__num {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: var(--accent-strong);
  color: var(--text-on-accent);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.market-step__body h3 {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  letter-spacing: var(--tracking-tight);
}
.market-step__body p {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
}

/* Stats strip — dark bg */
.market-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-8);
  text-align: center;
}
.market-stat__num {
  font-family: var(--font-sans);
  font-size: clamp(40px, 5vw, 56px);
  font-weight: var(--weight-bold);
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-2);
}
.market-stat__label {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-on-chrome-dim);
  font-weight: var(--weight-medium);
}

/* Pricing teaser */
.market-pricing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-5);
  max-width: 1000px;
  margin: 0 auto;
}
.market-pricing-card {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  display: flex;
  flex-direction: column;
  position: relative;
}
.market-pricing-card--featured {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 1px var(--accent-strong), var(--shadow-md);
}
.market-pricing-card__tag {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-1) var(--space-3);
  background: var(--accent-strong);
  color: var(--text-on-accent);
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.market-pricing-card__name {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.market-pricing-card__price {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
}
.market-pricing-card__price-amount {
  font-family: var(--font-sans);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: var(--tracking-tight);
}
.market-pricing-card__price-period {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.market-pricing-card__sub {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-5);
  line-height: var(--leading-normal);
}
.market-pricing-card__list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}
.market-pricing-card__list li {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  padding-left: var(--space-5);
  position: relative;
  line-height: var(--leading-snug);
}
.market-pricing-card__list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 12px;
  height: 8px;
  border-left: 2px solid var(--color-green-500);
  border-bottom: 2px solid var(--color-green-500);
  transform: rotate(-45deg);
}
.market-pricing-card .btn { width: 100%; justify-content: center; }

/* Bottom CTA card */
.market-cta-card {
  background: linear-gradient(135deg, var(--surface-chrome) 0%, #1E1040 100%);
  border-radius: var(--radius-2xl);
  padding: var(--space-12) var(--space-8);
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.market-cta-card::before {
  content: "";
  position: absolute;
  top: -80px; right: -80px;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(196, 181, 253, 0.25), transparent 70%);
}
.market-cta-card h2 {
  font-family: var(--font-sans);
  font-size: clamp(24px, 3.4vw, 36px);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-on-chrome);
  margin-bottom: var(--space-3);
  position: relative;
  z-index: 1;
}
.market-cta-card p {
  color: var(--text-on-chrome-dim);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  margin-bottom: var(--space-8);
  position: relative;
  z-index: 1;
}
.market-cta-card .btn { position: relative; z-index: 1; }

/* Footer */
.market-footer {
  background: #07050F;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding: var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}
.market-footer__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
}
.market-footer__brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.market-footer__brand-mark svg { width: 16px; height: 16px; color: var(--text-on-accent); }
.market-footer__wordmark {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: rgba(255, 255, 255, 0.7);
}
.market-footer__copy {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.32);
}
.market-footer__links {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
}
.market-footer__link {
  color: rgba(255, 255, 255, 0.45);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  transition: color var(--motion-fast);
}
.market-footer__link:hover { color: rgba(255, 255, 255, 0.85); }

@media (max-width: 640px) {
  .market-hero { padding: var(--space-12) var(--space-4) var(--space-10); }
  .market-section { padding: var(--space-12) var(--space-4); }
  .market-cta-card { padding: var(--space-10) var(--space-5); }
  .market-footer { flex-direction: column; text-align: center; }
}

/* ──────────────────────────────────────────────────────────────────────────
 * §3.15 — Density modes (brief §5.4)
 *   data-density="compact" reduces row height + padding on data-heavy surfaces.
 *   Type scale is intentionally NOT changed (per brief).
 * ──────────────────────────────────────────────────────────────────────── */

body[data-density="compact"] .run-table th,
body[data-density="compact"] .table th    { padding: 5px 10px; }
body[data-density="compact"] .run-table td,
body[data-density="compact"] .table td    { padding: 6px 10px; }

body[data-density="compact"] .card        { padding: 14px 16px; }

body[data-density="compact"] .cal-cell    { min-height: 80px; padding: 4px 6px; }

body[data-density="compact"] .platform-card .platform-body { padding: 10px 12px; }
body[data-density="compact"] .platform-card .platform-header { padding: 8px 12px; }

body[data-density="compact"] .phase-card  { padding: 16px 20px; }
body[data-density="compact"] .publish-summary { padding: 16px 20px; }

/* ──────────────────────────────────────────────────────────────────────────
 * §4.3 — Run lifecycle (run-detail, review, schedule)
 *   Brief §6 — phase ribbon, two-column shell, metadata rail.
 * ──────────────────────────────────────────────────────────────────────── */

/* 4.3.1 Phase ribbon — horizontal 4-step Generating · Review · Publishing · Published */
.phase-ribbon {
  display: flex;
  gap: 0;
  margin-bottom: var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}
.phase-ribbon__step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 12px 16px;
  position: relative;
  color: var(--text-tertiary);
  border-right: 1px solid var(--border-subtle);
  background: var(--surface-raised);
  text-decoration: none;
}
.phase-ribbon__step:last-child { border-right: none; }
.phase-ribbon__step--done {
  color: var(--text-secondary);
  background: var(--color-ink-100);
}
.phase-ribbon__step--current {
  color: var(--accent-strong);
  font-weight: var(--weight-semibold);
  background: var(--accent-soft-bg);
}
.phase-ribbon__step--failed {
  color: var(--color-red-700);
  background: var(--color-red-50);
}
.phase-ribbon__num {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-pill);
  background: var(--color-ink-200);
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.phase-ribbon__step--done .phase-ribbon__num    { background: var(--color-green-500); color: var(--text-on-accent); }
.phase-ribbon__step--current .phase-ribbon__num { background: var(--accent-strong);   color: var(--text-on-accent); }
.phase-ribbon__step--failed .phase-ribbon__num  { background: var(--color-red-500);   color: var(--text-on-accent); }
.phase-ribbon__name {
  font-family: var(--font-sans);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.phase-ribbon__step--done .phase-ribbon__num::before { content: ""; width: 10px; height: 6px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg) translate(1px, -1px); }
.phase-ribbon__step--done .phase-ribbon__num { font-size: 0; }

@media (max-width: 720px) {
  .phase-ribbon { flex-direction: column; }
  .phase-ribbon__step { border-right: none; border-bottom: 1px solid var(--border-subtle); padding: 10px 14px; }
  .phase-ribbon__step:last-child { border-bottom: none; }
}

/* 4.3.2 Two-column run shell (main + sticky right rail) */
.run-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--space-6);
  align-items: start;
}
.run-shell__main { min-width: 0; }
.run-shell__rail {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  position: sticky;
  top: 80px;
}
@media (max-width: 960px) {
  .run-shell { grid-template-columns: 1fr; }
  .run-shell__rail { position: static; }
}

/* 4.3.3 Metadata rail card */
.meta-rail {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  font-family: var(--font-sans);
}
.meta-rail__title {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-3);
}
.meta-rail__list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
}
.meta-rail__row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-sm);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--border-subtle);
}
.meta-rail__row:first-child { border-top: none; }
.meta-rail__label {
  color: var(--text-tertiary);
  font-weight: var(--weight-medium);
  flex-shrink: 0;
}
.meta-rail__value {
  color: var(--text-primary);
  text-align: right;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}
.meta-rail__brief {
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.meta-rail__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}
.meta-rail__actions .btn { width: 100%; justify-content: center; }

/* 4.3.4 Run-detail header (above ribbon): breadcrumb + title + status pill */
.run-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.run-header__crumb {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  text-decoration: none;
  margin-bottom: var(--space-1);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.run-header__crumb:hover { color: var(--text-secondary); }
.run-header__title {
  font-family: var(--font-sans);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  margin-top: var(--space-1);
}
.run-header__meta {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  flex-wrap: wrap;
}
.run-header__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

/* 4.3.5 Review-page two-column 65/35 split (brief §6 review) */
.review-split {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr);  /* ~65/35 */
  gap: var(--space-5);
  align-items: start;
}
@media (max-width: 960px) {
  .review-split { grid-template-columns: 1fr; }
}

/* 4.3.6 Stage tracker — brief §6 generating phase ("stage-by-stage live progress") */
.stage-tracker {
  list-style: none;
  padding: 0;
  margin: var(--space-5) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.stage-tracker__step {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  transition: background var(--motion-base) var(--easing-standard),
              color var(--motion-base) var(--easing-standard);
}
.stage-tracker__step--done    { color: var(--text-secondary); }
.stage-tracker__step--active  { color: var(--accent-stronger); background: var(--accent-soft-bg); }
.stage-tracker__step--failed  { color: var(--color-red-700); background: var(--color-red-50); }
.stage-tracker__step--pending { color: var(--text-tertiary); }

.stage-tracker__icon {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}
.stage-tracker__step--done    .stage-tracker__icon { background: var(--color-green-500); color: var(--text-on-accent); }
.stage-tracker__step--active  .stage-tracker__icon { background: var(--accent-strong);   color: var(--text-on-accent); }
.stage-tracker__step--failed  .stage-tracker__icon { background: var(--color-red-500);   color: var(--text-on-accent); }
.stage-tracker__step--pending .stage-tracker__icon { background: var(--color-ink-200); }

.stage-tracker__icon svg { width: 12px; height: 12px; }

.stage-tracker__step--active .stage-tracker__icon::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--radius-pill);
  animation: var(--motion-spin);
}
.stage-tracker__step--pending .stage-tracker__icon::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--color-ink-400);
  border-radius: var(--radius-pill);
}
.stage-tracker__name { flex: 1; }
.stage-tracker__hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ──────────────────────────────────────────────────────────────────────────
 * §4.4 — Dashboard (calendar-first)
 * ──────────────────────────────────────────────────────────────────────── */

/* Platform filter chips above the calendar */
.cal-platform-filter {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
}
.cal-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 5px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
}
.cal-filter-chip:hover {
  background: var(--accent-soft-bg);
  border-color: var(--accent-strong);
  color: var(--accent-stronger);
}
.cal-filter-chip.cal-filter-active {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--text-on-accent);
}
.cal-filter-chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* When a single-platform filter is active, hide chips that don't match */
.cal-grid.cal-filtered .cal-article-chip[data-platforms]:not([data-platforms*="--current--"]) {
  display: none;
}

/* ──────────────────────────────────────────────────────────────────────────
 * §4.5 — Stragglers (legacy class aliases used by sparse templates)
 * ──────────────────────────────────────────────────────────────────────── */

/* Billing template uses .badge-ok / .badge-muted — wire to canonical tokens */
.badge-ok      { display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill);
                 font-size: var(--text-xs); font-weight: var(--weight-semibold);
                 text-transform: uppercase; letter-spacing: var(--tracking-wide);
                 background: var(--status-published-bg); color: var(--status-published-text); }
.badge-muted   { display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill);
                 font-size: var(--text-xs); font-weight: var(--weight-semibold);
                 text-transform: uppercase; letter-spacing: var(--tracking-wide);
                 background: var(--status-scheduled-bg); color: var(--status-scheduled-text); }

/* Billing uses .main-content as a wrapper — simple alias for .page padding */
.main-content {
  max-width: 980px;
  margin: 0 auto;
  padding: var(--space-2) 0;
  font-family: var(--font-sans);
}
.main-content h1 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-4);
  color: var(--text-primary);
}


/* ── Restored 2026-04-30: AI assistant widget styles (copied from prod) ─── */
.ai-fab {
  position: fixed;
  bottom: 76px;
  right: 24px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 10px 16px 10px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(124,58,237,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.ai-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(124,58,237,0.45); }
.ai-fab svg { flex-shrink: 0; }

.ai-panel {
  display: none;
  flex-direction: column;
  position: fixed;
  bottom: 80px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 48px rgba(12,10,26,0.28);
  z-index: 1001;
  overflow: hidden;
}
.ai-panel.open { display: flex; }

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: linear-gradient(135deg, #7C3AED, #10B981);
  color: #fff;
  flex-shrink: 0;
}
.ai-panel-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
}
.ai-panel-header-left span.ai-model-badge {
  font-size: 10px;
  font-weight: 500;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 2px 7px;
  letter-spacing: 0.03em;
}
.ai-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}
.ai-close:hover { color: #fff; }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 90%;
}
.ai-msg.user  { align-self: flex-end; align-items: flex-end; }
.ai-msg.asst  { align-self: flex-start; align-items: flex-start; }

.ai-bubble {
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.ai-msg.user .ai-bubble {
  background: var(--green);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg.asst .ai-bubble {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ai-typing {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 9px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.ai-typing span {
  width: 6px; height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: ai-bounce 1.2s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.ai-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: #fff;
}
.ai-input {
  flex: 1;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.45;
  overflow-y: auto;
}
.ai-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(124,58,237,0.12); }
