/* ============================================================ */
/* DESIGN SYSTEM */
/* ============================================================ */
:root {
  /* SURFACES */
  --bg-main: #0a0a0a;
  --bg-raised: #1a1a1a;
  --bg-surface: rgba(255, 255, 255, 0.02);
  --bg-surface-hover: rgba(255, 255, 255, 0.04);
  --bg-elevated: rgba(255, 255, 255, 0.05);
  --bg-elevated-hover: rgba(255, 255, 255, 0.08);
  --bg-elevated-strong: rgba(255, 255, 255, 0.1);
  --bg-hover-soft: rgba(255, 255, 255, 0.06);
  --card-bg: rgba(255, 255, 255, 0.03);

  /* TEXT */
  --text-main: #e8e8ea;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.35);
  --text-on-accent: #fff;
  --text-on-btn: #0a0a0a;

  /* BORDERS */
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.18);

  /* BRAND / STATUS */
  /* accent is a live global_setting: R,G,B channels are set by JS at boot.
     every other variant (soft, softer, border, accent, accent-soft) is
     derived from those channels, so changing the accent propagates through
     the whole UI (tags, borders, backgrounds, blobs, etc) automatically. */
  --color-primary-r: 244;
  --color-primary-g: 63;
  --color-primary-b: 94;
  --color-primary: rgb(var(--color-primary-r), var(--color-primary-g), var(--color-primary-b));
  --color-primary-soft: rgba(var(--color-primary-r), var(--color-primary-g), var(--color-primary-b), 0.15);
  --color-primary-border: rgba(var(--color-primary-r), var(--color-primary-g), var(--color-primary-b), 0.3);
  --color-accent: var(--color-primary);
  --color-accent-soft: var(--color-primary-soft);

  --color-success: #34d399;
  --color-success-soft: rgba(52, 211, 153, 0.1);
  --color-success-border: rgba(52, 211, 153, 0.2);

  --color-info: #60a5fa;
  --color-info-strong: rgba(96, 165, 250, 0.18);

  --color-warning: #fbbf24;
  --color-warning-soft: rgba(251, 191, 36, 0.1);
  --color-warning-border: rgba(251, 191, 36, 0.2);

  --color-error: #f87171;
  --color-error-soft: rgba(239, 68, 68, 0.1);
  --color-error-border: rgba(239, 68, 68, 0.3);

  /* NEUTRALS (for logs / misc tags) */
  --color-purple: #a855f7;
  --color-purple-soft: rgba(168, 85, 247, 0.15);

  /* PLATFORMS */
  --color-tiktok: #60a5fa;
  --color-tiktok-soft: rgba(96, 165, 250, 0.1);
  --color-tiktok-border: rgba(96, 165, 250, 0.3);
  --color-youtube: #ef4444;

  /* TYPE PALETTE — injected dynamically from DB by helpers.js loadConceptMeta() */

  /* INPUTS / BUTTONS */
  --btn-bg: #f0f0f2;
  --btn-bg-hover: #d8d8da;
  --btn-text: #0a0a0a;
  --input-bg: rgba(255, 255, 255, 0.03);
  --input-border: rgba(255, 255, 255, 0.07);
  --input-focus-bg: rgba(255, 255, 255, 0.05);
  --input-focus-border: rgba(255, 255, 255, 0.18);

  /* DECOR */
  --blob-a: rgba(var(--color-primary-r), var(--color-primary-g), var(--color-primary-b), 0.08);
  --blob-b: rgba(255, 255, 255, 0.02);
  --line-accent: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.15) 50%, transparent 100%);
  --overlay-scrim: rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);

  /* RADII / SPACING */
  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 10px;
  --radius-pill: 20px;
  --space-xxs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3rem;

  /* PIXEL SPACING SCALE (complements rem --space-*) */
  --sp-1:  2px;
  --sp-2:  4px;
  --sp-3:  6px;
  --sp-4:  8px;
  --sp-5:  10px;
  --sp-6:  12px;
  --sp-7:  14px;
  --sp-8:  16px;
  --sp-10: 20px;
  --sp-12: 24px;
  --sp-16: 32px;

  /* ADDITIONAL RADII */
  --radius-xxs: 2px;
  --radius-xs:  3px;
  --radius-md:  8px;

  /* FONT SIZE SCALE */
  --fs-3xs: 0.6rem;
  --fs-2xs: 0.65rem;
  --fs-xs:  0.7rem;
  --fs-sm:  0.75rem;
  --fs-base:0.8rem;
  --fs-md:  0.85rem;
  --fs-lg:  0.95rem;
  --fs-xl:  1.1rem;
  --fs-2xl: 1.4rem;
  --fs-3xl: 1.6rem;
  --fs-4xl: 2.4rem;

  /* MISC SURFACES */
  --bg-black: #000;
  --bg-nav: rgba(10, 10, 10, 0.6);
  --bg-scroll-thumb: rgba(255, 255, 255, 0.1);
  --bg-scroll-thumb-hover: rgba(255, 255, 255, 0.2);
  --shadow-up: 0 -4px 16px rgba(0, 0, 0, 0.25);

  /* TYPOGRAPHY */
  --font-mono: 'SF Mono', 'Fira Code', ui-monospace, monospace;

  /* MISC */
  --grain-opacity: 0.25;
  --grain-scale: 1;
  --transition: 0.15s ease;
  --nav-height: 48px;

  /* Z-INDEX LAYERING SCALE
     Use these instead of literal numbers so new features slot into the
     stacking order without fighting ad-hoc values. Local stacking within
     a component (1/2/3 tiny offsets) is fine as a literal — these vars
     are for global layers that cross components. */
  --z-sticky: 100;    /* sticky headers, docked toolbars inside scroll areas */
  --z-docked: 500;    /* bottom bars / side docks that float over content */
  --z-modal: 900;     /* nav / app-shell overlays below popups */
  --z-overlay: 1000;  /* full-screen modal overlays (video player, popups) */
  --z-popover: 1100;  /* context menus + dropdowns floating over modals */
  --z-toast: 10000;   /* toasts always above every overlay */
  --z-topmost: 99999; /* last-resort pinning (drag ghosts, critical alerts) */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-scroll-thumb); border-radius: var(--radius-xs); }
::-webkit-scrollbar-thumb:hover { background: var(--bg-scroll-thumb-hover); }
::-webkit-scrollbar-corner { background: transparent; }

html { font-size: 14px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
}

/* ============================================================ */
/* BACKGROUND */
/* ============================================================ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 15% 10%, var(--blob-a) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 90%, var(--blob-b) 0%, transparent 50%);
}

/* ============================================================ */
/* LAYOUT */
/* ============================================================ */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================================ */
/* NAV */
/* ============================================================ */
.nav {
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: var(--bg-nav);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.nav-brand {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-sep {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 var(--space-xxs);
  flex-shrink: 0;
}

.nav-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

.nav-link:hover { color: var(--text-main); }
.nav-link.active { color: var(--text-main); }

.nav-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================ */
/* MAIN */
/* ============================================================ */
.main {
  flex: 1;
  padding: var(--space-lg);
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-height: 0;
}

/* PAGE TOOLBAR: shared header row for filters/search/actions on every tab */
.page-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}
.page-toolbar .grow { flex: 1; }
.page-toolbar .spacer { flex: 1; }

/* SECTION HEADER: small header above a panel (title + actions) */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  font-size: 0.85rem;
  font-weight: 500;
}
.panel-head .panel-head-actions { display: flex; gap: 6px; align-items: center; }
.panel-head .panel-count { color: var(--text-muted); font-weight: 400; }

/* PANEL: scrollable content column (used in schedule/import layouts) */
.panel-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 0;
  min-height: 0;
}
.panel-col.grow { flex: 1; }
.panel-col .panel-scroll { flex: 1; overflow-y: auto; min-height: 0; }

/* FILTER BUTTON: shared pill used across dashboard, library, stats tabs */
.filter-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 4px 14px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.filter-btn:hover { color: var(--text-main); border-color: var(--border-hover); }
.filter-btn.active {
  background: var(--bg-elevated-hover);
  color: var(--text-main);
  border-color: var(--text-muted);
}
.filter-btn.icon { padding: 4px 10px; }
.filter-group { display: flex; gap: 4px; align-items: center; }

/* DIVIDER: vertical separator inside toolbars */
.v-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 0 var(--space-xxs);
}

/* UTILITIES */
.hidden { display: none !important; }

/* SKELETON: pulsing placeholder used while a card/page is loading.
   `.skel` animates on its own; `.skel-block` is a sized shortcut;
   `.skel-text` is a line-of-text shortcut. Add `.is-loading` on a
   container to hide its live contents while skeletons are visible. */
@keyframes skel-pulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 0.9; }
}
.skel {
  background: linear-gradient(90deg,
    var(--bg-surface-hover) 0%,
    var(--bg-elevated) 50%,
    var(--bg-surface-hover) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: skel-pulse 1.2s ease-in-out infinite;
}
.skel-block { width: 100%; height: 100%; }
.skel-text {
  height: 0.9em;
  width: 60%;
  margin: 4px 0;
}
.is-loading > :not(.skel):not(.skel-overlay) { visibility: hidden; }
.skel-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: inherit;
}

/* DASHBOARD-SPECIFIC SKELETON SHAPES */
.skel-kpi { display: inline-block; width: 3.5em; height: 1em; vertical-align: middle; }
.skel-row { height: 22px; margin-bottom: 4px; }
/* card overlay: covers a whole chart-card (title + chart) while loading.
   the parent gets .is-loading-card which marks it position: relative so
   the absolute overlay lays out against the card itself. */
.is-loading-card { position: relative; }
.is-loading-card > :not(.skel-card-overlay) { visibility: hidden; }
.skel-card-overlay { position: absolute; inset: 0; }

/* TYPE STATS ROW: list of type badges above a queue. Keeps a fixed slot
   even when empty so the layout below (quick-add, list) doesn't jump when
   badges are added or removed. */
.type-stats-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 26px;
  align-content: flex-start;
  margin-bottom: var(--space-sm);
}

/* ============================================================ */
/* BUTTONS */
/* ============================================================ */
.btn {
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn:hover {
  color: var(--text-main);
  border-color: var(--border-hover);
  background: var(--bg-surface-hover);
}

.btn-primary {
  background: var(--btn-bg);
  color: var(--btn-text);
  /*transparent border keeps total box height identical to bordered variants (.btn, .btn-danger).
    without this, action bars that mix a primary button with bordered buttons grow a couple of
    pixels the moment the bordered buttons appear, because .btn-sm overrides the old padding
    compensation and leaves .btn-primary without any border contribution to its height.*/
  border: 1px solid transparent;
  font-weight: 600;
  padding: 6px 15px;
}

.btn-primary:hover { background: var(--btn-bg-hover); color: var(--btn-text); }

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-danger {
  color: var(--color-error);
  border-color: var(--color-error-border);
}

.btn-danger:hover {
  border-color: var(--color-error);
  background: var(--color-error-soft);
}

/* armed state for two-click delete confirmation */
.btn-danger.btn-confirm-armed,
.btn-danger.btn-confirm-armed:hover {
  background: var(--color-error);
  color: var(--text-on-accent);
  border-color: var(--color-error);
}

.btn-success {
  color: var(--color-success);
  border-color: var(--color-success-border);
}

.btn-success:hover {
  border-color: var(--color-success);
  background: var(--color-success-soft);
}

.btn-sm {
  font-size: 0.75rem;
  padding: 4px 10px;
}

/* ============================================================ */
/* SECTION HEADERS */
/* ============================================================ */
.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ============================================================ */
/* CARDS */
/* ============================================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
}

/* ============================================================ */
/* STATUS BAR */
/* ============================================================ */
.status-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 8px var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.ready { background: var(--color-success); }
.status-dot.published { background: var(--color-info); }

/* ============================================================ */
/* SERVER WIDGET */
/* ============================================================ */
.server-widget {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: var(--z-modal);
}

.server-widget-btn {
  padding: 6px 14px;
  font-size: 0.7rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.server-widget-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-main);
}

.server-widget-list {
  display: none;
  flex-direction: column;
  gap: 2px;
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  min-width: 160px;
}

.server-widget.open .server-widget-list { display: flex; }

.server-widget-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.server-widget-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.server-widget-dot.online { background: var(--color-success); }
.server-widget-dot.offline { background: var(--color-error); }

/* ============================================================ */
/* EMPTY STATE */
/* ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ============================================================ */
/* AUTH PAGE */
/* ============================================================ */
.auth-page {
  flex: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-blobs {
  position: fixed;
  inset: -50%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 20%, var(--blob-a) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, var(--blob-b) 0%, transparent 50%);
  animation: blob-drift 12s ease-in-out infinite alternate;
}

@keyframes blob-drift {
  0% { transform: translate(-18%, -18%) rotate(0deg); }
  100% { transform: translate(18%, 18%) rotate(5deg); }
}

.auth-grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background:
    radial-gradient(ellipse at 20% 20%, var(--blob-a) 0%, transparent 100%),
    radial-gradient(ellipse at 80% 80%, var(--blob-b) 0%, transparent 100%);
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  mask-size: calc(512px * var(--grain-scale));
  mask-repeat: repeat;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  -webkit-mask-size: calc(512px * var(--grain-scale));
  -webkit-mask-repeat: repeat;
}

.auth-container {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 380px;
  padding: 40px;
}

.auth-topline {
  position: absolute;
  top: 0;
  left: 40px;
  right: 40px;
  height: 1px;
  background: var(--line-accent);
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 32px;
  letter-spacing: -0.02em;
}

.auth-buttons {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.auth-btn-google {
  padding: 12px 16px;
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--transition);
}

.auth-btn-google:hover { border-color: var(--input-focus-border); }

.auth-error {
  font-size: 12px;
  color: var(--color-error);
}

/* ============================================================ */
/* FOOTER */
/* ============================================================ */
.footer {
  padding: var(--space-md);
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.footer a:hover { color: var(--text-secondary); }

/* ============================================================ */
/* TOAST */
/* ============================================================ */
/* stack container: newest toast at the bottom, older ones push up.
   column-reverse means the first child is at the bottom, so toast.ts
   prepends new toasts and the visual order stays newest-at-bottom. */
#toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-topmost);
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
/* regular toasts keep their previous visual width, error progress toasts
   get to grow wider (see .toast-progress-error-expanded below) */
.toast { max-width: 360px; }
.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: var(--text-main);
  background: var(--bg-raised);
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.toast-msg {
  flex: 1;
  min-width: 0;
}
.toast-copy {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 6px;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: all var(--transition);
}
.toast-copy:hover {
  border-color: var(--border-hover);
  color: var(--text-main);
}
.toast-close {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 6px;
  display: flex;
  align-items: center;
  transition: all var(--transition);
}
.toast-close:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.toast-progress {
  min-width: 280px;
  padding: 12px 16px;
}
.toast-progress-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.toast-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-elevated-strong);
  border-radius: var(--radius-xxs);
  overflow: hidden;
}
.toast-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--color-info);
  border-radius: var(--radius-xxs);
  transition: width 0.2s ease;
}
.toast-progress.toast-success .toast-progress-fill { background: var(--color-success); }
.toast-progress.toast-error .toast-progress-fill { background: var(--color-primary); }
.toast-progress.toast-warning .toast-progress-fill { background: var(--color-warning, #eab308); }

/* error/warning progress toasts: let the message wrap and make the toast
   wider so the full server error is actually readable instead of cut off */
.toast-msg { word-break: break-word; }
.toast-progress-error-expanded {
  max-width: 520px !important;
  min-width: 320px;
}
.toast-progress-error-expanded .toast-msg {
  white-space: pre-wrap;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.72rem;
  line-height: 1.35;
}

/* ============================================================ */
/* POPUP */
/* ============================================================ */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-toast);
  opacity: 0;
  transition: opacity 0.2s;
}
.popup-overlay.show { opacity: 1; }
.popup-box {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  min-width: 400px;
  max-width: 540px;
}
.popup-box p {
  margin: 0 0 24px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-main);
}
.popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.popup-box .popup-sub {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.popup-list {
  margin: 0 0 16px;
  padding: 8px 12px 8px 28px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-main);
}
.popup-list li {
  margin: 2px 0;
}

/* RUN PILE MODAL (Run confirmation - read-only list of items to generate) */
.run-pile-box {
  min-width: 320px;
  max-width: 560px;
  width: 100%;
  display: flex;
  flex-direction: column;
}
.run-pile-box h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--text-main);
}
.run-pile-box .run-pile-sub {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.run-pile-list {
  margin: 0 0 16px;
  padding: 4px;
  max-height: 50vh;
  overflow-y: auto;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-main);
  list-style: none;
}
.run-pile-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.run-pile-item:last-child { border-bottom: none; }
.run-pile-item .rp-idx {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: right;
}
.run-pile-item .rp-type {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-muted);
}
.run-pile-item .rp-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.run-pile-item .rp-date {
  color: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* Run pile progress (displayed during active run) */
.run-pile-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.run-pile-progress .rpp-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-main);
  border-radius: var(--radius-xxs);
  overflow: hidden;
  min-width: 80px;
}
.run-pile-progress .rpp-fill {
  height: 100%;
  background: var(--color-primary);
  transition: width 0.3s;
}

@media (max-width: 600px) {
  .popup-box, .run-pile-box {
    min-width: 0;
    width: calc(100vw - 24px);
    padding: 20px 16px;
  }
  .popup-actions {
    flex-direction: column-reverse;
  }
  .popup-actions .btn {
    width: 100%;
  }
  .run-pile-item .rp-date { display: none; }
}
