/* ============================================
   Vigen AI — Design System Tokens
   ============================================ */

/* DARK MODE (default) */
:root {
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-base: 15px;
  --font-size-lg: 17px;

  /* Backgrounds — layered for depth */
  --bg-base:     #111117;
  --bg-surface:  #18181F;
  --bg-elevated: #22222E;
  --bg-hover:    #2A2A38;

  /* Borders — visible but subtle */
  --border:       rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);

  /* Text — clear contrast hierarchy */
  --text-primary:   #EFEFEF;
  --text-secondary: #9A9AB0;
  --text-muted:     #5A5A72;

  /* Accent & brand */
  --accent:        #F97316;
  --accent-hover:  #EA6A08;
  --accent-subtle: rgba(249, 115, 22, 0.14);
  --premium:       #818CF8;

  /* Status */
  --success:       #22C55E;
  --pending:       #F59E0B;
  --info:          #3B82F6;
  --danger:        #F43F5E;
  --danger-light:  rgba(244, 63, 94, 0.12);

  /* Elevation shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);

  /* Sidebar size tokens */
  --sidebar-expanded:  220px;
  --sidebar-collapsed: 60px;
  --topbar-height:     56px;

  /* Transitions */
  --transition-fast:   150ms ease-out;
  --transition-normal: 250ms ease-out;

  /* Backwards-compat aliases */
  --bg-main:      var(--bg-base);
  --bg-card:      var(--bg-surface);
  --bg-input:     var(--bg-elevated);
  --border-color: var(--border);
  --border-focus: var(--accent);
  --primary:      var(--bg-elevated);
  --accent-light: var(--accent-subtle);
}

/* LIGHT MODE */
body.light-mode {
  --bg-base:     #F4F4F8;
  --bg-surface:  #FFFFFF;
  --bg-elevated: #EEEEF4;
  --bg-hover:    #E4E4EC;

  --border:       rgba(0, 0, 0, 0.09);
  --border-strong: rgba(0, 0, 0, 0.18);

  --text-primary:   #111118;
  --text-secondary: #5A5A72;
  --text-muted:     #9A9AB0;

  --accent:        #EA6508;
  --accent-hover:  #D45900;
  --accent-subtle: rgba(234, 101, 8, 0.10);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.14);

  --bg-main:      var(--bg-base);
  --bg-card:      var(--bg-surface);
  --bg-input:     var(--bg-elevated);
  --border-color: var(--border);
}

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

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

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ── Layout shell ───────────────────────────── */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 1536px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Topbar ─────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 50;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.topbar-center {
  flex: 1;
  max-width: 400px;
}

.brand {
  font-weight: 700;
  font-size: var(--font-size-lg);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  letter-spacing: -0.5px;
}

.brand .logo {
  color: var(--accent);
  margin-right: 6px;
}

.global-search {
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  gap: 8px;
  width: 100%;
  color: var(--text-secondary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.global-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.global-search i {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.global-search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  width: 100%;
  font-family: inherit;
  font-size: var(--font-size-sm);
}

.global-search input::placeholder {
  color: var(--text-muted);
}

.icon-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

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

.icon-btn i { width: 18px; height: 18px; }

.notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  border: 1.5px solid var(--bg-surface);
}

/* Theme toggle */
.theme-toggle {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  transition: var(--transition-fast);
  flex-shrink: 0;
}
.theme-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.theme-toggle i { width: 18px; height: 18px; }

.avatar-dropdown { position: relative; }

.avatar {
  background: var(--accent-subtle);
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--accent);
  transition: var(--transition-fast);
  font-weight: 600;
  font-size: var(--font-size-sm);
}

.avatar:hover {
  background: var(--accent);
  color: #fff;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem;
  min-width: 200px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
}

.dropdown-header {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-email {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--font-size-sm);
  transition: var(--transition-fast);
  text-align: left;
}

.dropdown-item i {
  width: 16px;
  height: 16px;
}

.dropdown-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.dropdown-item.text-danger {
  color: var(--danger);
}

.dropdown-item.text-danger:hover {
  background: var(--danger-light);
}

/* ── Sidebar ────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  height: calc(100vh - var(--topbar-height));
  background: var(--bg-surface);
  border-right: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-fast);
  z-index: 40;
  overflow-y: auto;
  overflow-x: visible; /* allow toggle btn to peek out */
  box-shadow: var(--shadow-md);
}

.sidebar.expanded  { width: var(--sidebar-expanded); }
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.5rem;
  gap: 0.25rem;
  flex: 1;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 0.75rem;
  margin: 0.75rem 0 0.25rem;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  width: 100%;
  text-align: left;
}

.nav-item i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.nav-item.active {
  color: var(--accent);
  background: var(--accent-subtle);
  font-weight: 600;
}

/* Only show left-bar accent on expanded sidebar */
.sidebar.expanded .nav-item.active {
  border-left: 2.5px solid var(--accent);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  padding-left: calc(0.75rem - 2.5px);
}

.nav-label {
  transition: opacity var(--transition-fast);
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar.collapsed .nav-label  { opacity: 0; width: 0; }
.sidebar.expanded  .nav-label  { opacity: 1; }

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 0.75rem;
}

.text-premium { color: var(--premium); }

.pill-count {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 99px;
  margin-left: auto;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Sidebar Toggle Button ───────────────────── */
.sidebar-toggle {
  position: absolute;
  top: 1.25rem;
  right: -16px;          /* half of 32px width */
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);           /* orange by default — impossible to miss */
  border: 2px solid rgba(255,255,255,0.25);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 45;
  box-shadow: 0 0 0 3px var(--accent-subtle), var(--shadow-md);
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--accent-hover);
  transform: scale(1.15);
  box-shadow: 0 0 0 5px var(--accent-subtle), var(--shadow-lg);
}

.sidebar-toggle:active {
  transform: scale(0.92);
}

.sidebar-toggle i {
  width: 15px;
  height: 15px;
  transition: transform var(--transition-normal);
  stroke-width: 2.5;
}

.sidebar.collapsed .sidebar-toggle i { transform: rotate(180deg); }

/* ── Main Content ───────────────────────────── */
.main-content {
  flex: 1;
  margin-top: var(--topbar-height);
  margin-left: var(--sidebar-expanded);
  transition: margin-left var(--transition-fast);
  min-height: calc(100vh - var(--topbar-height));
  display: flex;
  flex-direction: column;
  align-items: center;   /* ← centres content horizontally */
}

.main-content.collapsed {
  margin-left: var(--sidebar-collapsed);
}

/* ── Container inside main-content acts as page wrapper ── */
.main-content .container {
  width: 100%;          /* fill the flex column */
  max-width: 1100px;    /* cap width for readability */
  margin: 0 auto;       /* center within the flex column */
  padding: 2rem 1.5rem;
}

@media (max-width: 768px) {
  .main-content .container { padding: 1rem; }
}

/* ── Bottom Nav (Mobile only) ──────────────── */
.bottom-nav { display: none; }

/* ── Responsive ─────────────────────────────── */
@media (max-width: 1200px) {
  /* On tablet collapse sidebar by default */
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar .nav-label { opacity: 0; width: 0; }
  .sidebar.expanded .nav-label { opacity: 1; width: auto; }
  .main-content { margin-left: var(--sidebar-collapsed); }
  .main-content.expanded-sidebar { margin-left: var(--sidebar-expanded); }
}

@media (max-width: 768px) {
  :root {
    --topbar-height: 50px;
  }
  .topbar-center { display: none; }
  .sidebar { display: none; }
  .sidebar-toggle { display: none; }

  .main-content {
    margin-left: 0;
    min-height: calc(100vh - var(--topbar-height) - 60px);
    padding-bottom: 20px;
  }


  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-strong);
    justify-content: space-around;
    align-items: center;
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
  }

  .bnav-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 10px;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    border-radius: 8px;
  }

  .bnav-item i { width: 22px; height: 22px; }

  .bnav-item.active {
    color: var(--accent);
    transform: scale(1.05);
  }
}

/* Grid layout */
.main-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* Editorial Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.25s ease-out;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

/* Form Controls & Styling */
.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  position: relative;
}

.form-group:has(.custom-dropdown-container.open) {
  z-index: 100;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.flex-row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Styled Inputs */
.input-control, .select-control, .textarea-control {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-family: 'Space Grotesk', monospace;
  font-size: 0.9rem;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  outline: none;
  transition: all 0.2s ease-out;
  box-shadow: var(--shadow-sm);
}

.input-control:disabled, .select-control:disabled, .textarea-control:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: rgba(255, 255, 255, 0.04);
}

.select-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%235c5c57'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.25rem;
}

.textarea-control {
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
  line-height: 1.5;
}

.input-control:focus, .select-control:focus, .textarea-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Buttons */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease-out;
  font-family: 'Outfit', sans-serif;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--accent);
  color: #ffffff;
  border: none;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(249,115,22,0.3);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  background-color: var(--bg-elevated);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-secondary {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

/* Category Tabs navigation */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease-out;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.tab-btn.active {
  background: var(--accent-light);
  color: var(--accent);
}

/* Sub-category tabs navigation */
.sub-category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 1.25rem;
  padding: 4px 0;
}

.sub-tab-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease-out;
  box-shadow: none;
}

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

.sub-tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(249,115,22,0.3);
}

/* Info Box */
.info-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.info-label {
  color: var(--text-secondary);
  font-weight: 600;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  margin-left: 6px;
}

.badge-info {
  background-color: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(255, 107, 0, 0.2);
}

.badge-secondary {
  background-color: #eae9e4;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.badge-pending {
  background-color: rgba(204, 84, 0, 0.08);
  color: var(--pending);
  border: 1px solid rgba(204, 84, 0, 0.2);
}

.badge-success {
  background-color: rgba(5, 150, 105, 0.08);
  color: var(--success);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.badge-danger {
  background-color: rgba(220, 38, 38, 0.08);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

/* Warning Box */
.warning-box {
  color: var(--danger);
  font-weight: 500;
  margin-bottom: 1.25rem;
  font-size: 0.8rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(220, 38, 38, 0.05);
  border: 1px solid rgba(220, 38, 38, 0.15);
  line-height: 1.5;
  text-align: left;
}

/* Custom Checkbox (Toggle style) */
.toggle-control-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem !important;
  font-weight: 500 !important;
}

.toggle-control-label input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-control-label span::before {
  content: '';
  display: inline-block;
  width: 34px;
  height: 20px;
  background-color: var(--bg-hover);
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
}

.toggle-control-label span::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  background-color: var(--text-muted);
  border-radius: 50%;
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease;
}

/* Positional adjustments for toggle switch circle */
.toggle-control-label span {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.toggle-control-label input:checked + span::before {
  background-color: var(--accent);
  border-color: var(--accent);
}

.toggle-control-label input:checked + span::after {
  transform: translateY(-50%) translateX(14px);
  background-color: #ffffff;
}

/* Minimal Checkbox container for forms */
.checkbox-container {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
}

.checkbox-container input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Queue List styling */
.desc-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.queue-list-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.queue-item {
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.queue-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.queue-item-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.queue-item-prompt {
  font-size: 0.75rem;
  color: var(--text-secondary);
  word-break: break-word;
  font-family: 'Space Grotesk', monospace;
}

.progress-container {
  width: 100%;
  height: 4px;
  background-color: #eae9e4;
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: var(--accent);
  width: 0;
  transition: width 0.3s ease;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border: 1px dashed var(--border-color);
  border-radius: 8px;
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 0.5rem;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  background-color: #eae9e4;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.gallery-item:hover {
  transform: scale(1.02);
}

.gallery-item.selected {
  border: 3px solid var(--accent) !important;
  transform: scale(0.96) !important;
}
.gallery-item.selected::before {
  content: '✓';
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--accent);
  color: #ffffff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  z-index: 5;
  box-shadow: var(--shadow-sm);
}

.gallery-item img, .gallery-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-meta {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(10, 10, 10, 0.85);
  color: #ffffff;
  padding: 6px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.65rem;
  backdrop-filter: blur(4px);
}

.gallery-meta span:first-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 75%;
}

.gallery-meta .badge {
  font-size: 0.55rem;
  padding: 1px 3px;
  margin: 0;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #ffffff;
}

/* MODEL LIBRARY VIEW STYLING */
#library-view {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.library-header-wrapper {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .library-header-wrapper {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
  }
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.library-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease-out;
  min-height: 160px;
}

.library-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--text-muted);
}

.lib-card-top {
  margin-bottom: 0.75rem;
}

.lib-model-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.lib-model-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.lib-model-provider {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.lib-model-subcategory {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-hover);
  border: 1px solid var(--border-strong);
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.02em;
}

.lib-model-cost-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.75rem;
  font-weight: 500;
}

.lib-model-cost-val {
  font-weight: 700;
  color: var(--accent);
}

.lib-card-actions {
  display: flex;
  justify-content: flex-end;
  border-t: 1px solid var(--border-color);
  padding-top: 0.5rem;
  margin-top: 0.5rem;
}

.btn-bookmark {
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-bookmark:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-bookmark.bookmarked {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* DYNAMIC MULTI-IMAGE FIELDS */
.multi-image-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  background: rgba(15, 15, 15, 0.01);
}

.multi-image-row {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.2s ease-out;
}

.multi-image-row input[type="file"] {
  flex: 1;
}

.btn-remove-image {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 1rem;
  font-weight: bold;
  border-radius: 4px;
  transition: background 0.2s;
}

.btn-remove-image:hover {
  background: rgba(220, 38, 38, 0.1);
}

.add-image-btn {
  background: transparent;
  border: 1px dashed var(--accent);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 4px;
}

.add-image-btn:hover {
  background: var(--accent-light);
}

.add-image-btn:disabled {
  border-color: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
  background: transparent;
}

/* Animations */
.animate-fade {
  animation: fadeIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

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

/* Field Description */
.field-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 400;
  line-height: 1.4;
}

/* Responsive Media Queries */
@media (max-width: 768px) {
  .app-header {
    padding: 1rem;
    gap: 0.75rem;
  }
  
  .header-top-row {
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
  }
  
  .brand {
    justify-content: center;
  }
  
  .user-session {
    justify-content: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }

  .nav-tab-btn {
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
  }

  .library-header-wrapper {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .library-search-wrapper {
    max-width: 100% !important;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 1rem 0.5rem;
  }

  .card {
    padding: 1rem;
    border-radius: 8px;
  }

  .category-tabs {
    gap: 4px;
  }

  .tab-btn {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
    font-size: 0.8rem;
    padding: 0.45rem 0.5rem;
  }

  .sub-tab-btn {
    font-size: 0.72rem;
    padding: 0.3rem 0.5rem;
  }
}

/* Toast Notifications Container */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-surface);
  border-left: 4px solid var(--accent);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 300px;
  max-width: 400px;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  opacity: 0;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toast-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.toast-close {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  line-height: 1;
}

.toast-close:hover {
  color: var(--text-primary);
}

.toast-body {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

.toast-action-btn {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(255, 107, 0, 0.2);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  transition: all 0.2s;
}

.toast-action-btn:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* Modal Overlay & Content */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(10, 10, 10, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 1.5rem;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  font-size: 1.5rem;
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  line-height: 1;
}

.modal-close:hover {
  background: var(--bg-main);
  border-color: var(--text-muted);
}

.modal-body {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  overflow: hidden;
  height: 100%;
  min-height: 0;
}

@media (max-width: 768px) {
  .modal-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
}

.modal-media-container {
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  max-height: 100%;
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: relative;
}

@media (min-width: 769px) {
  .modal-media-container {
    height: 100%;
    max-height: 100%;
  }
}

.modal-media-container img, .modal-media-container video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.modal-details {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  overflow-y: auto;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-model-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.modal-prompt {
  font-family: 'Space Grotesk', monospace;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  background: var(--bg-main);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-actions-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 480px) {
  .modal-actions-row {
    flex-direction: row;
  }
  .modal-actions-row .btn {
    flex: 1;
  }
}

/* Range Slider Custom Styling */
.slider-wrapper {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

.slider-wrapper:focus-within {
  border-color: var(--border-focus);
}

.slider-control {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  height: 20px;
}

.slider-control:focus {
  outline: none;
}

/* Track styles */
.slider-control::-webkit-slider-runnable-track {
  background: var(--border-color);
  border-radius: 4px;
  height: 6px;
}

.slider-control::-moz-range-track {
  background: var(--border-color);
  border-radius: 4px;
  height: 6px;
}

/* Thumb styles */
.slider-control::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  background: var(--accent);
  border-radius: 50%;
  height: 16px;
  width: 16px;
  margin-top: -5px; /* Centers the thumb on the track */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s, background-color 0.2s;
}

.slider-control::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background: var(--primary);
}

.slider-control::-moz-range-thumb {
  background: var(--accent);
  border: none;
  border-radius: 50%;
  height: 16px;
  width: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s, background-color 0.2s;
}

.slider-control::-moz-range-thumb:hover {
  transform: scale(1.15);
  background: var(--primary);
}

.slider-value {
  color: var(--text-primary);
  background: var(--accent-light);
  border: 1px solid rgba(255, 107, 0, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: monospace;
}

/* Right Sidebar Parameter Config Drawer (Overlay) */
.sidebar-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2000;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 10, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.drawer-content {
  position: relative;
  width: 480px;
  max-width: 100%;
  height: 100%;
  background-color: var(--bg-main);
  border-left: 1px solid var(--border-color);
  box-shadow: -8px 0 32px rgba(10, 10, 10, 0.08);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-drawer-overlay.open .drawer-content {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg-surface);
}

.drawer-title-area {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.drawer-title-area h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.drawer-close {
  border: none;
  background: transparent;
  font-size: 1.75rem;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  line-height: 1;
  border-radius: 50%;
}

.drawer-close:hover {
  background: rgba(10, 10, 10, 0.05);
  color: var(--text-primary);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* Model Cards List View (Left Panel) */
.model-list-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
  margin-top: 0.5rem;
}

.model-card-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.model-card-item:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-1px);
}

.model-card-item.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 1px var(--accent);
}

.model-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.model-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.model-card-provider {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.model-card-cost {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Custom Premium Dropdown Styles */
.custom-dropdown-container {
  position: relative;
  width: 100%;
  margin-bottom: 0.25rem;
}

.custom-dropdown-container.open {
  z-index: 100;
}

.custom-dropdown-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.75rem;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease-out;
  box-shadow: var(--shadow-sm);
  font-family: inherit;
  font-size: 0.9rem;
  min-height: 40px;
}

.custom-dropdown-trigger:hover {
  border-color: var(--text-muted);
}

.custom-dropdown-trigger:focus, 
.custom-dropdown-container.open .custom-dropdown-trigger {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.custom-dropdown-trigger .chevron {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.custom-dropdown-container.open .chevron {
  transform: rotate(180deg);
}

.custom-dropdown-popover {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  margin-top: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
  box-sizing: border-box !important;
  max-width: 100% !important;
}

.custom-dropdown-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
  box-sizing: border-box !important;
  overflow: hidden !important;
  min-width: 0 !important;
  width: 100% !important;
}

.custom-dropdown-option:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.custom-dropdown-option.selected {
  font-weight: 600;
  background: rgba(255, 107, 0, 0.04);
  color: var(--accent);
}

.custom-dropdown-option .option-text {
  flex: 1;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  text-align: left;
}

.custom-dropdown-option .checkmark {
  color: var(--accent);
  font-weight: bold;
  font-size: 0.9rem;
  flex-shrink: 0;
  margin-left: 8px;
}
/* PREMIUM MEDIA UPLOADER CARDS */
.media-upload-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
  width: 100%;
}

.media-upload-card {
  position: relative;
  background: var(--bg-input);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 90px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  width: 100%;
}

.media-upload-card:hover {
  border-color: var(--accent);
  background: rgba(255, 107, 0, 0.01);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.media-upload-card:active {
  transform: translateY(0);
}

.media-upload-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-light);
  color: var(--accent);
  flex-shrink: 0;
  transition: all 0.25s ease;
}

.media-upload-card:hover .media-upload-icon {
  background: var(--accent);
  color: #ffffff;
}

.media-upload-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.media-upload-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-upload-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* File selected state */
.media-upload-card.has-file {
  border-style: solid;
  border-color: var(--border-color);
}

.media-upload-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  z-index: 5;
  animation: fadeIn 0.2s ease-out;
}

.preview-media-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.preview-media-wrapper img, .preview-media-wrapper video, .preview-media-wrapper .video-placeholder-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  background: #15151a;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.preview-media-wrapper img:hover, .preview-media-wrapper video:hover, .preview-media-wrapper .video-placeholder-thumb:hover {
  transform: scale(1.05);
  filter: brightness(1.1);
}

.preview-media-wrapper .video-placeholder-thumb svg {
  width: 24px;
  height: 24px;
}

.media-upload-preview-details {
  flex: 1;
  margin-left: 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.media-upload-preview-filename {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-upload-preview-filesize {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.btn-remove-media {
  background: #eae9e4;
  border: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 700;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  margin-left: 8px;
  padding: 0;
}

.btn-remove-media:hover {
  background: var(--danger);
  color: #ffffff;
}


@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* ═══════════════════════════════════════════
   WORKFLOW BUILDER STYLES
═══════════════════════════════════════════ */

/* ═══ 3-Column Flat Workflow Layout ════════════════════════ */
.workflow-layout-3col {
  display: grid;
  grid-template-columns: 260px 1fr 340px;
  gap: 1.25rem;
  min-height: calc(100vh - 120px);
  align-items: start;
}

/* Legacy 2-col (kept for reference, not used) */
.workflow-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.25rem;
  min-height: calc(100vh - 120px);
  align-items: start;
}

@media (max-width: 1300px) {
  .workflow-layout-3col {
    grid-template-columns: 220px 1fr 300px;
  }
}

@media (max-width: 1024px) {
  .workflow-layout-3col {
    grid-template-columns: 1fr;
  }
  .workflow-layout {
    grid-template-columns: 1fr;
  }
  .workflow-mobile-header {
    display: flex;
  }
  .workflow-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -100% !important;
    height: 100vh !important;
    width: 280px !important;
    max-height: 100vh !important;
    z-index: 1001 !important;
    border-radius: 0 !important;
    transition: left 0.3s ease;
    margin: 0;
  }
  .workflow-sidebar.open {
    left: 0 !important;
  }
  .workflow-sidebar-backdrop.open {
    display: block;
  }
  #btn-close-workflow-sidebar {
    display: block;
  }
}

/* Mobile Drawer Extras */
.workflow-mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 0.5rem 0;
}
.workflow-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  backdrop-filter: blur(2px);
}
#btn-close-workflow-sidebar {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-primary);
  line-height: 1;
}

/* Left Column: Workflow List */
.workflow-sidebar {
  position: sticky;
  top: 1.5rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.workflow-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.btn-sidebar-import {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-sidebar-import:hover {
  background: var(--border-color);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-sidebar-import svg {
  color: var(--text-secondary);
}

.btn-new-workflow {
  width: 100%;
  justify-content: center;
  padding: 0.8rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-new-workflow:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.25);
}

.workflow-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
}

.workflow-list::-webkit-scrollbar {
  width: 4px;
}

.workflow-list-item {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.85rem 1.15rem;
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.workflow-list-item::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
  opacity: 0;
  transition: var(--transition-fast);
}

.workflow-list-item:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: translateX(2px);
}

.workflow-list-item.active {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: var(--shadow-sm);
}

.workflow-list-item.active::after {
  opacity: 1;
}

.workflow-list-item-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workflow-list-item-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.workflow-list-item-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Placeholder State */
.workflow-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 5rem 2rem;
  text-align: center;
  background: var(--bg-card);
  border: 2px dashed var(--border-strong);
  border-radius: 20px;
  min-height: 420px;
  box-shadow: var(--shadow-sm);
}

.placeholder-icon {
  font-size: 3.5rem;
  filter: drop-shadow(0 4px 12px rgba(249,115,22,0.25));
  animation: pulse-ring 2.5s infinite;
}

.workflow-placeholder h3 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  margin-top: 0.5rem;
}

.workflow-placeholder p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 420px;
  line-height: 1.6;
}

/* Editor Panel */
/* Middle Column: Steps Editor (flat, no card wrapper) */
.workflow-editor-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

/* Legacy editor panel (if needed) */
.workflow-editor-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow-md);
}

.workflow-editor-header {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.workflow-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.workflow-name-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 250px;
}

.workflow-edit-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  opacity: 0.5;
  pointer-events: none;
}

.workflow-name-input {
  width: 100%;
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  padding-left: 2.35rem !important;
  background-color: var(--bg-main) !important;
  border-color: var(--border-color) !important;
}

.workflow-name-input:focus {
  background-color: var(--bg-elevated) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-subtle) !important;
}

.workflow-action-buttons {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.workflow-action-buttons .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.65rem 1.15rem;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-save-action {
  background-color: var(--accent);
  color: #ffffff;
  border: none;
}

.btn-save-action:hover:not(:disabled) {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-export-action {
  background-color: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-export-action:hover:not(:disabled) {
  background-color: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text-primary);
  transform: translateY(-1px);
}

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

.btn-danger-action:hover:not(:disabled) {
  background-color: var(--danger-light);
  transform: translateY(-1px);
}

.btn-icon-svg {
  flex-shrink: 0;
}

/* Two-Column Editor Layout */
/* workflow-editor-grid defined below at line ~3018 — single source of truth */

@media (max-width: 900px) {
  .workflow-editor-grid {
    grid-template-columns: 1fr;
  }
}

/* Steps Container */
.workflow-steps-container {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Step Card */
.workflow-step-card {
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  transition: var(--transition-normal);
  background: var(--bg-main);
  box-shadow: var(--shadow-sm);
}

.workflow-step-card:hover {
  border-color: var(--slate-300);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.workflow-step-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle), var(--shadow-md);
  background: var(--bg-elevated);
}

.step-card-header {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 1rem;
  padding: 1.15rem 1.35rem;
  cursor: pointer;
  user-select: none;
}

.step-number-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.workflow-step-card.active .step-number-badge {
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.step-card-info {
  min-width: 140px;
  overflow: hidden;
}

.step-model-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-model-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.step-card-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.badge-type {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-type.image { background: rgba(59, 130, 246, 0.15); color: #60A5FA; }
.badge-type.video { background: rgba(16, 185, 129, 0.15); color: #34D399; }
.badge-type.threed { background: rgba(167, 139, 250, 0.15); color: #A78BFA; }

.badge-credit {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-subtle);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(249, 115, 22, 0.25);

}

.step-card-actions {
  display: flex;
  align-items: center;
  background: var(--bg-base);
  padding: 4px;
  border-radius: 10px;
  gap: 3px;
  border: 1px solid var(--border);
}

.btn-step-action {
  background: transparent;
  border: none;
  border-radius: 7px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition: var(--transition-fast);
  color: var(--text-secondary);
}

.btn-step-action:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.btn-step-action[title="Hapus"]:hover,
.btn-step-action[title="Remove Step"]:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* Step parameters body */
.step-params-body {
  border-top: 1px solid var(--border-color);
  padding: 1.25rem;
  background: var(--bg-elevated);
  animation: slideIn 0.25s ease-out;
}

.step-auto-input-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--success);
  background: rgba(34, 197, 94, 0.10);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 20px;
  padding: 0.35rem 0.85rem;
  margin-bottom: 1rem;
}

/* Connector between steps */
.step-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.65rem 0;
  position: relative;
}

.step-connector-line {
  width: 2px;
  height: 28px;
  background: linear-gradient(to bottom, var(--accent), var(--border-color));
  border-radius: 1px;
}

.step-connector-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid rgba(249, 115, 22, 0.25);
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  margin: 0.25rem 0;
  letter-spacing: 0.05em;
  box-shadow: var(--shadow-sm);
}

/* Add step row */
.workflow-add-step-row {
  display: flex;
  justify-content: center;
  padding: 0.75rem 0;
}

.workflow-add-step-row .btn {
  border-radius: 12px;
  padding: 0.8rem 1.5rem;
  border: 2px dashed var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
  font-weight: 700;
  font-size: 0.88rem;
  transition: var(--transition-fast);
  box-shadow: none;
}

.workflow-add-step-row .btn:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(249,115,22,0.3);
  border-style: solid;
}

/* Credit Bar */
.workflow-credit-bar {
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  padding: 1.15rem 1.35rem;
  background: var(--bg-main);
  transition: var(--transition-normal);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.workflow-credit-bar.level-ok { border-color: #10b981; background: rgba(16, 185, 129, 0.02); }
.workflow-credit-bar.level-warn { border-color: #f59e0b; background: rgba(245, 158, 11, 0.02); }
.workflow-credit-bar.level-danger { border-color: #ef4444; background: rgba(239, 68, 68, 0.02); }

.credit-bar-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.credit-bar-label {
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.credit-bar-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif;
}

.workflow-credit-bar.level-ok .credit-bar-value { color: #10b981; }
.workflow-credit-bar.level-warn .credit-bar-value { color: #f59e0b; }
.workflow-credit-bar.level-danger .credit-bar-value { color: #ef4444; }

.credit-breakdown {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.credit-breakdown-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.25rem 0.6rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.workflow-errors {
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--danger);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: 10px;
}

.workflow-error-item::before { content: "⚠️ "; }

/* Run Button */
.btn-run-workflow {
  width: 100%;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.95rem;
  margin-top: 1.25rem;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.15);
  border: none;
}

.btn-run-workflow:hover:not(:disabled) {
  background-color: var(--accent-hover);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.3);
}

/* Settings Sidebar — proper dark-mode card */
.workflow-step-settings-sidebar {
  position: sticky;
  top: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 400px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  /* Always visible as col 3 */
  align-self: start;
}

.workflow-step-settings-sidebar:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.step-settings-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 3rem 1.5rem;
  gap: 0.85rem;
}

.step-settings-empty span {
  font-size: 2.5rem;
  opacity: 0.4;
  animation: pulse-ring 2.5s infinite;
}

.step-settings-empty h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.step-settings-empty p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.step-settings-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 0.5rem;
}

.step-settings-model-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.step-settings-model-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.step-settings-params-divider {
  margin: 1.25rem 0;
  border-top: 1px solid var(--border-color);
}

/* ── Premium Media Uploader Cards in Workflow ──────────────── */

.dropzone-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ── Batch Run Toggle Buttons ────────────────────────────── */
.batch-count-buttons .batch-btn {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
}
.batch-count-buttons .batch-btn.active {
  background-color: var(--accent) !important;
  color: #ffffff !important;
  border-color: var(--accent) !important;
  box-shadow: 0 4px 12px rgba(255, 107, 0, 0.25) !important;
}

/* ── Analytics Styles ────────────────────────────────────── */
.analytics-metrics-grid .metric-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.analytics-metrics-grid .metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.chart-bar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}

.chart-bar {
  width: 36px;
  background: linear-gradient(180deg, var(--accent) 0%, #ff8b38 100%);
  border-radius: 6px 6px 0 0;
  transition: height 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  position: relative;
  box-shadow: 0 2px 6px rgba(255, 107, 0, 0.1);
}

.chart-bar:hover {
  background: linear-gradient(180deg, #ff8b38 0%, #ffa366 100%);
  box-shadow: 0 4px 12px rgba(255, 107, 0, 0.3);
}

/* Tooltip on Hover */
.chart-bar-tooltip {
  position: absolute;
  bottom: 100%;
  background: rgba(10, 10, 10, 0.9);
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'Space Grotesk', monospace;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px) scale(0.9);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  margin-bottom: 6px;
  z-index: 10;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.chart-bar-wrapper:hover .chart-bar-tooltip {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Analytics lists styling */
.analytics-row-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  transition: background 0.15s ease;
}

.analytics-row-item:hover {
  background: var(--bg-hover);
}

.analytics-row-name {
  font-weight: 500;
  color: var(--text-primary);
}

.analytics-row-value {
  font-weight: 700;
  color: var(--accent);
  font-family: 'Space Grotesk', monospace;
}

.analytics-row-duration {
  font-weight: 700;
  color: var(--text-secondary);
  font-family: 'Space Grotesk', monospace;
}

/* ── Two-Column Workflow Editor Layout ────────────────────── */
.workflow-editor-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1.5rem;
  align-items: start;
  margin-top: 1.5rem;
}

.workflow-editor-left-col {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}



/* ── Placeholder Templates ──────────────────────────────── */
.workflow-placeholder-templates {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  text-align: left;
}

/* ── Templates Catalog Styles ────────────────────────────── */
#workflow-templates-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}
#workflow-templates-catalog-grid .card {
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
#workflow-templates-catalog-grid .card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

/* ── Analytics Metric Grid & Card Styles ─────────────────── */
.analytics-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}
.analytics-metrics-grid .metric-card {
  padding: 1.5rem;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}
.analytics-metrics-grid .metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.analytics-metrics-grid .metric-card h3 {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.analytics-metrics-grid .metric-card .metric-val {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif;
}
.analytics-metrics-grid .metric-card .metric-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Fix Analytics Daily Usage Chart styles */
#analytics-chart-container {
  display: flex;
  height: 220px;
  gap: 16px;
  align-items: flex-end;
  padding: 1.5rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}
#chart-dates-row {
  display: flex;
  gap: 16px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-family: 'Space Grotesk', monospace;
}

/* ── Authentication Overlay (Premium Glassmorphism) ── */
#auth-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  background: rgba(245, 244, 242, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  text-align: left;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-card:hover {
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.08);
}

.auth-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  text-align: center;
  letter-spacing: -0.5px;
}

.auth-switch {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s ease;
}

.auth-switch a:hover {
  color: #cc5400;
}

/* ── Weavy Accounts Grid & List Styles ── */
.accounts-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

@media (max-width: 768px) {
  .accounts-grid {
    grid-template-columns: 1fr;
  }
}

.user-accounts-list-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.account-item {
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

/* Left accent line */
.account-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--border-strong);
  border-radius: 14px 0 0 14px;
  transition: background 0.2s ease;
}

.account-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.account-item:hover::before {
  background: var(--accent);
}


/* ── Step Model Selection Modal & Grid Styles ── */
.step-model-modal-content {
  max-width: 720px;
  width: 95%;
  padding: 2rem;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}

.step-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.step-modal-header h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.step-modal-filter-info {
  font-size: 0.82rem;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid rgba(79, 70, 229, 0.15);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  margin-bottom: 1.25rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.step-model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  overflow-y: auto;
  max-height: 55vh;
  padding: 4px 6px 4px 4px;
}

.step-model-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.15rem;
  cursor: pointer;
  transition: var(--transition-normal);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: none;
  position: relative;
  overflow: hidden;
}

.step-model-card::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
  opacity: 0;
  transition: var(--transition-fast);
}

.step-model-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.step-model-card:hover::after {
  opacity: 1;
}

.step-model-card-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.35;
}

.step-model-card-meta {
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.step-model-card-cost {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: auto;
  padding-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── Workflow Run Monitor (Floating Premium Panel) ── */
.workflow-run-monitor {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 360px;
  max-height: 480px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideInUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.run-monitor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-strong);
}

.run-monitor-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-close-monitor {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition-fast);
}

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

.run-steps-list {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow-y: auto;
  max-height: 320px;
}

.run-step-item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: var(--transition-fast);
}

.run-step-item.running {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.run-step-item.completed {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.02);
}

.run-step-item.failed {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.02);
}

.run-step-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.run-step-item.waiting .run-step-icon {
  background: var(--bg-main);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.run-step-item.running .run-step-icon {
  background: var(--accent-light);
  color: var(--accent);
}

.run-step-item.completed .run-step-icon {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.run-step-item.failed .run-step-icon {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.spin-icon {
  animation: spin 1.5s linear infinite;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

.run-step-info {
  flex: 1;
  min-width: 0;
}

.run-step-model {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.run-step-status {
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.run-step-progress {
  width: 100%;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.run-step-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0;
  transition: width 0.3s ease;
}

.run-step-preview, .run-step-preview-video {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  margin-top: 0.5rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.run-step-preview:hover, .run-step-preview-video:hover {
  transform: scale(1.05);
  border-color: var(--accent);
}

.run-final-result {
  padding: 1.25rem;
  background: var(--bg-main);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.run-final-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--success);
}

.run-final-media {
  width: 100%;
  max-height: 180px;
  border-radius: 12px;
  object-fit: contain;
  border: 1px solid var(--border-color);
  background: #000;
}

/* Local Task Queue styling */
.local-task-item {
  border: 1px solid var(--border-color);
  border-left: 4px solid #ff3366;
  background-color: var(--bg-input);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.local-task-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
  transform: translateX(4px);
}

.local-task-content {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.local-task-meta {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.btn-local-item-delete {
  background: none;
  border: none;
  color: #ff5252;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: opacity 0.2s;
}

.btn-local-item-delete:hover {
  opacity: 0.8;
}

/* PWA UI/UX Enhancements */
#offline-badge {
  transition: all var(--transition-normal);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: var(--shadow-sm);
}

#offline-badge span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  position: relative;
}

#offline-badge:not([data-was-offline="true"]) span {
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse-green 2s infinite;
}

#offline-badge[data-was-offline="true"] span {
  background-color: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  animation: pulse-red 2s infinite;
}

#btn-install-pwa {
  animation: pulse-install 2.5s infinite;
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  transition: all var(--transition-fast);
}

#btn-install-pwa:hover {
  background: var(--accent) !important;
  color: #fff !important;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulse-red {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes pulse-install {
  0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.2); }
  70% { box-shadow: 0 0 0 8px rgba(79, 70, 229, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}

/* Standalone Display Mode tweaks for App Feel */
@media (display-mode: standalone) {
  body {
    background-color: #0f172a; /* Darker header feel in PWA */
  }
  .container {
    padding: 1rem 1rem;
  }
  .app-header {
    border-radius: 0;
    border-top: none;
    border-left: none;
    border-right: none;
    margin-bottom: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
  }
}

/* SweetAlert2 z-index fix to display above modal overlays */
.swal2-container {
  z-index: 100000 !important;
}

/* Prevent auto zoom-in on focus in mobile browsers by ensuring text inputs are at least 16px */
@media (max-width: 768px) {
  .input-control, 
  .select-control, 
  .textarea-control, 
  input[type="text"], 
  input[type="email"], 
  input[type="password"], 
  select, 
  textarea {
    font-size: 16px !important;
  }
}

/* Dynamic parameters flex/grid layout on desktop to show media upload cards side-by-side */
@media (min-width: 769px) {
  #dynamic-fields-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
  }
  #dynamic-fields-container > .form-group {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 220px;
    margin-bottom: 0.5rem;
  }
  #dynamic-fields-container > .form-group.hidden {
    display: none !important;
  }
  /* For form-groups that do NOT have a media card, let them span 100% width */
  #dynamic-fields-container > .form-group:not(:has(.media-upload-card)) {
    flex: 1 1 100%;
  }
}

/* ── WORKFLOW MOBILE LAYOUT & STEP CARD MOBILITY/DRAWER STYLES ── */

/* Mobile Header for Workflow section */
.workflow-mobile-header {
  display: none;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 10px;
  width: 100%;
}

.workflow-mobile-header .btn {
  flex: 1;
  justify-content: center;
  font-size: 0.85rem;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Backdrop for Mobile Sidebar Drawer */
.workflow-sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 10, 10, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1999;
  transition: opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.workflow-sidebar-backdrop.open {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* Close button for drawer sidebar */
#btn-close-workflow-sidebar {
  display: none;
  font-size: 1.8rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

/* Mobile responsive media query */
@media (max-width: 768px) {
  .workflow-mobile-header {
    display: flex !important;
  }

  /* Make sidebar behave as a drawer sliding from the left */
  .workflow-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -320px !important;
    width: 290px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    z-index: 2000 !important;
    border-radius: 0 !important;
    border: none !important;
    border-right: 1px solid var(--border-strong) !important;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.4) !important;
    transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  .workflow-sidebar.open {
    left: 0 !important;
  }

  #btn-close-workflow-sidebar {
    display: inline-flex !important;
  }
}

/* Step Card layout for very narrow screens (mobile responsive header) */
@media (max-width: 576px) {
  .step-card-header {
    grid-template-columns: auto 1fr !important;
    grid-template-rows: auto auto auto !important;
    gap: 0.5rem 0.75rem !important;
    padding: 1rem !important;
  }
  .step-number-badge {
    grid-row: 1 / 3 !important;
    align-self: start !important;
    margin-top: 2px !important;
  }
  .step-card-info {
    grid-column: 2 !important;
    min-width: 0 !important;
  }
  .step-card-badges {
    grid-column: 2 !important;
    margin-top: 0.25rem !important;
    justify-content: flex-start !important;
  }
  .step-card-actions {
    grid-column: 1 / -1 !important;
    justify-content: space-between !important;
    width: 100% !important;
    margin-top: 0.5rem !important;
    background: var(--bg-hover) !important;
  }
  .btn-step-action {
    flex: 1 !important;
    height: 32px !important;
  }
}

/* Workflow Studio refresh: scoped light workspace inspired by the compact builder view */
#workflow-view {
  background: var(--bg-base);
  color: var(--text-primary);
  margin: -2rem -1.5rem;
  padding: 1.75rem 1.5rem 3rem;
  min-height: calc(100vh - var(--topbar-height));
}

#workflow-view .workflow-layout-3col {
  grid-template-columns: minmax(230px, 270px) minmax(0, 1fr) minmax(310px, 360px);
  gap: 1.25rem;
  max-width: 1536px;
  margin: 0 auto;
  min-height: auto;
}

#workflow-view .workflow-sidebar,
#workflow-view .workflow-editor-header,
#workflow-view .workflow-step-settings-sidebar,
#workflow-view .workflow-credit-bar,
#workflow-view .workflow-placeholder {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: none;
}

#workflow-view .workflow-sidebar {
  top: calc(var(--topbar-height) + 1rem);
  padding: 1rem;
  gap: 0.85rem;
  max-height: calc(100vh - 96px);
}

#workflow-view .workflow-sidebar-header {
  border-bottom: 0;
  padding-bottom: 0;
}

#workflow-view .workflow-sidebar-header .panel-title {
  font-size: 1rem;
}

#workflow-view .btn-sidebar-import,
#workflow-view .workflow-action-buttons .btn,
#workflow-view .btn-step-action,
#workflow-view .workflow-add-step-row .btn {
  min-height: 32px;
  border-radius: 7px;
  box-shadow: none;
}

#workflow-view .btn-new-workflow {
  background: var(--accent);
  border-radius: 9px;
  box-shadow: none;
  min-height: 42px;
}

#workflow-view .workflow-list {
  gap: 0.6rem;
  max-height: calc(100vh - 240px);
}

#workflow-view .workflow-list-item {
  background: var(--bg-main);
  border-color: var(--border-color);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  box-shadow: none;
}

#workflow-view .workflow-list-item:hover {
  background: var(--accent-subtle);
  transform: none;
}

#workflow-view .workflow-list-item.active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

#workflow-view .workflow-list-item::after {
  display: none;
}

#workflow-view #workflow-editor-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
}

#workflow-view .workflow-editor-header {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#workflow-view .workflow-name-row {
  align-items: stretch;
  gap: 0.65rem;
  flex-wrap: nowrap;
}

#workflow-view .workflow-name-input-wrapper {
  min-width: 0;
}

#workflow-view .workflow-edit-icon {
  display: none;
}

#workflow-view .workflow-name-input {
  height: 38px;
  padding-left: 0.75rem !important;
  font-family: var(--font-sans) !important;
  font-size: 0.9rem !important;
  font-weight: 700 !important;
  border-radius: 7px;
  background: var(--bg-input) !important;
}

#workflow-view .workflow-action-buttons {
  gap: 0.5rem;
  flex-wrap: nowrap;
}

#workflow-view .workflow-action-buttons .btn {
  padding: 0 0.85rem;
  font-size: 0.78rem;
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-primary);
}

#workflow-view .workflow-action-buttons .btn-save-action {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

#workflow-view .workflow-action-buttons .btn-danger-action {
  color: #e11d48;
  border-color: #e11d48;
  background: transparent;
}

#workflow-view .workflow-steps-container {
  margin-top: 1.25rem !important;
}

#workflow-view .workflow-step-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: none;
  overflow: visible;
}

#workflow-view .workflow-step-card:hover {
  border-color: var(--border-strong);
  box-shadow: none;
  transform: none;
}

#workflow-view .workflow-step-card.active {
  border-color: var(--accent);
  background: var(--accent-subtle);
  box-shadow: inset 0 0 0 1px var(--accent);
}

#workflow-view .step-card-header {
  grid-template-columns: 30px minmax(0, 1fr) max-content max-content;
  min-height: 52px;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
}

#workflow-view .step-number-badge {
  width: 24px;
  height: 24px;
  background: #050505;
  color: #ffffff;
  font-size: 0.74rem;
  box-shadow: none;
}

#workflow-view .workflow-step-card.active .step-number-badge {
  background: #050505;
  box-shadow: none;
}

#workflow-view .step-model-name {
  font-size: 0.86rem;
  margin-bottom: 0.05rem;
}

#workflow-view .step-card-info {
  min-width: 0;
}

#workflow-view .step-model-sub {
  font-size: 0.72rem;
}

#workflow-view .step-card-badges {
  gap: 0.3rem;
}

#workflow-view .badge-type {
  border-radius: 4px;
  padding: 0.2rem 0.42rem;
  font-size: 0.62rem;
}

#workflow-view .badge-type.image {
  background: #eaf0ff;
  color: #1d4ed8;
}

#workflow-view .badge-type.video {
  background: #defaf1;
  color: #047857;
}

#workflow-view .badge-type.threed {
  background: #f1ebff;
  color: #6d28d9;
}

#workflow-view .badge-credit {
  background: var(--accent-subtle);
  border-color: rgba(249, 115, 22, 0.28);
  color: var(--accent);
  border-radius: 5px;
  padding: 0.2rem 0.42rem;
  font-size: 0.72rem;
}

#workflow-view .step-card-actions {
  background: transparent;
  border: 0;
  padding: 0;
  gap: 0.35rem;
  min-width: 0;
}

#workflow-view .btn-step-action {
  width: 30px;
  height: 30px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  flex: 0 0 30px;
}

#workflow-view .btn-step-action:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  box-shadow: none;
}

#workflow-view .step-connector {
  padding: 0.45rem 0;
}

#workflow-view .step-connector-line {
  width: 1px;
  height: 22px;
  background: var(--accent);
}

#workflow-view .step-connector-label {
  font-size: 0.62rem;
  background: var(--accent-subtle);
  border-color: rgba(249, 115, 22, 0.28);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  box-shadow: none;
}

#workflow-view .workflow-add-step-row {
  padding: 0.9rem 0 1.25rem;
}

#workflow-view .workflow-add-step-row .btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0 1.25rem;
  font-weight: 700;
}

#workflow-view .workflow-add-step-row .btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
  transform: none;
  box-shadow: none;
}

#workflow-view .workflow-credit-bar {
  background: var(--bg-main);
  border-color: var(--border-color);
  border-radius: 10px;
  padding: 1rem;
}

#workflow-view .workflow-credit-bar.level-ok {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.45);
}

#workflow-view .workflow-credit-bar.level-warn {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.45);
}

#workflow-view .workflow-credit-bar.level-danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.45);
}

#workflow-view .credit-bar-label,
#workflow-view .credit-bar-value {
  color: var(--text-primary);
}

#workflow-view .credit-bar-value {
  font-size: 1.05rem;
}

#workflow-view .credit-breakdown-item {
  background: var(--bg-elevated);
  border-color: var(--border-color);
  border-radius: 5px;
  font-size: 0.7rem;
}

#workflow-view .workflow-errors {
  background: transparent;
  border: 0;
  padding: 0;
}

#workflow-view .btn-run-workflow {
  min-height: 42px;
  margin-top: 0.8rem;
  background: var(--accent);
  border-radius: 9px;
  box-shadow: none;
}

#workflow-view .btn-run-workflow:disabled {
  background: var(--bg-hover);
  color: var(--text-muted);
  opacity: 1;
}

#workflow-view .workflow-step-settings-sidebar {
  top: calc(var(--topbar-height) + 1rem);
  padding: 1.25rem;
  min-height: 420px;
  max-height: calc(100vh - 96px);
  box-shadow: none;
}

#workflow-view .workflow-step-settings-sidebar:hover {
  border-color: var(--border-color);
  box-shadow: none;
}

#workflow-view .step-settings-header {
  border-bottom-color: var(--border-color);
  padding-bottom: 0.85rem;
}

#workflow-view .step-settings-model-title {
  font-family: var(--font-sans);
  font-size: 1rem;
  letter-spacing: 0;
}

#workflow-view .step-settings-model-meta {
  font-size: 0.72rem;
}

#workflow-view .step-auto-input-badge {
  background: #e9fbf5;
  border-color: #a7ead5;
  color: #059669;
  border-radius: 999px;
  font-size: 0.7rem;
}

#workflow-view .step-settings-params-divider {
  border-top-color: var(--border-color);
}

#workflow-view .input-control,
#workflow-view .select-control,
#workflow-view .textarea-control {
  background: var(--bg-input);
  color: var(--text-primary);
  border-color: var(--border-color);
  border-radius: 7px;
  box-shadow: none;
  font-family: var(--font-sans);
}

#workflow-view .textarea-control {
  min-height: 98px;
}

#workflow-view .input-control:focus,
#workflow-view .select-control:focus,
#workflow-view .textarea-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 107, 18, 0.12);
}

#workflow-view .form-group label {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

#workflow-view .checkbox-container {
  color: var(--text-secondary) !important;
}

#workflow-view .media-upload-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  min-height: 64px;
  padding: 0.75rem;
  box-shadow: none;
}

#workflow-view .media-upload-card:hover {
  background: var(--bg-hover);
  box-shadow: none;
  transform: none;
}

#workflow-view .media-upload-icon {
  width: 36px;
  height: 36px;
  border-radius: 7px;
}

#workflow-view .media-upload-title {
  font-size: 0.8rem;
}

#workflow-view .media-upload-status {
  font-size: 0.7rem;
}

#workflow-view .media-upload-preview {
  background: var(--bg-elevated);
}

#workflow-view .step-settings-empty {
  padding: 3rem 1rem;
}

#workflow-view .step-settings-empty span {
  animation: none;
}

@media (max-width: 1180px) {
  #workflow-view .workflow-layout-3col {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  #workflow-view .workflow-step-settings-sidebar {
    position: static;
    grid-column: 2;
    max-height: none;
  }
}

@media (max-width: 1024px) {
  #workflow-view {
    margin: -1rem;
    padding: 1rem;
  }

  #workflow-view .workflow-layout-3col {
    grid-template-columns: 1fr;
  }

  #workflow-view .workflow-step-settings-sidebar {
    grid-column: auto;
  }

  #workflow-view .workflow-sidebar {
    background: var(--bg-card);
  }
}

@media (max-width: 720px) {
  #workflow-view #workflow-editor-content {
    padding: 0.75rem;
  }

  #workflow-view .workflow-name-row,
  #workflow-view .workflow-action-buttons {
    flex-wrap: wrap;
  }

  #workflow-view .workflow-action-buttons .btn {
    flex: 1 1 auto;
  }

  #workflow-view .step-card-header {
    grid-template-columns: 30px 1fr;
  }

  #workflow-view .step-card-badges,
  #workflow-view .step-card-actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}

/* ── Workflow Active Runs Container & Cards ── */
#workflow-view .workflow-active-runs-container {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#workflow-view .active-runs-header {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

#workflow-view .active-runs-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

#workflow-view .active-runs-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#workflow-view .active-run-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
}

#workflow-view .active-run-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

#workflow-view .active-run-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

#workflow-view .active-run-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#workflow-view .active-run-toggle-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

#workflow-view .active-run-cancel-btn:hover {
  background: rgba(239, 68, 68, 0.25) !important;
  border-color: rgba(239, 68, 68, 0.5) !important;
  color: #f87171 !important;
}

#workflow-view .active-run-toggle-btn:hover {
  background: var(--accent-subtle);
}

#workflow-view .active-run-close-btn {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s ease;
}

#workflow-view .active-run-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

#workflow-view .active-run-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

#workflow-view .active-run-body.collapsed {
  display: none;
}

#workflow-view .active-run-body .run-steps-list {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#workflow-view .active-run-body .run-step-item {
  background: var(--bg-base);
  border: 1px solid var(--border);
  padding: 0.65rem 0.85rem;
}

#workflow-view .active-run-body .run-final-result {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 0.85rem;
  margin: 0.5rem -1rem -1rem -1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* ── Workflow History Panel & Cards ── */
#workflow-view .workflow-history-section {
  margin-top: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#workflow-view .history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

#workflow-view .history-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

#workflow-view .workflow-history-list {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
}

.history-run-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.75rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.history-run-item:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.history-run-thumb {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.history-run-thumb-empty {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.history-run-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.history-run-date {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.history-run-status {
  font-size: 0.72rem;
  font-weight: 500;
}

.history-run-status.completed {
  color: var(--success);
}

.history-run-status.failed {
  color: var(--danger);
}

.history-run-status.running {
  color: var(--accent);
}

/* ── Mobile Hamburger Menu Button ── */
.hamburger-menu {
  display: none; /* Hide on desktop */
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background-color 0.2s;
}
.hamburger-menu:hover {
  background-color: var(--bg-hover);
}
.hamburger-menu i {
  width: 20px;
  height: 20px;
}

@media (max-width: 1024px) {
  .hamburger-menu {
    display: flex; /* Show on mobile/tablet */
  }
}

/* ── Mobile Sidebar Drawer & Backdrop ── */
@media (max-width: 768px) {
  .sidebar.active-mobile-sidebar {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: var(--sidebar-expanded) !important;
    max-width: 80vw !important;
    height: 100vh !important;
    z-index: 1200 !important;
    border-right: 1px solid var(--border-strong);
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
    background: var(--bg-surface);
    animation: slideInLeft 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.active-mobile-sidebar .nav-label {
    opacity: 1 !important;
    width: auto !important;
    display: inline-block !important;
  }

  .sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 1199;
    display: block;
    animation: fadeIn 0.25s ease-out;
  }
  
  .sidebar-backdrop.hidden {
    display: none !important;
  }
}

/* ── Mobile Workflow Settings Sidebar Drawer ── */
@media (max-width: 1024px) {
  #workflow-view .workflow-step-settings-sidebar {
    position: fixed !important;
    top: var(--topbar-height) !important;
    right: -100% !important; /* Hidden offscreen by default */
    width: 340px !important;
    max-width: 85vw !important;
    height: calc(100vh - var(--topbar-height) - 60px) !important;
    max-height: calc(100vh - var(--topbar-height) - 60px) !important;
    z-index: 1100 !important;
    margin: 0 !important;
    border-radius: 16px 0 0 16px !important;
    border: none !important;
    border-left: 1px solid var(--border-strong) !important;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5) !important;
    background: var(--bg-card) !important;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 1.5rem !important;
    align-self: auto !important;
  }

  #workflow-view .workflow-step-settings-sidebar.active-mobile {
    right: 0 !important; /* Slide in drawer */
  }

  #workflow-view .workflow-step-settings-sidebar #close-step-settings {
    display: block !important; /* Make close button visible on mobile */
  }
}

/* ── Upward-Opening Custom Dropdown ── */
.custom-dropdown-popover.open-upward {
  top: auto !important;
  bottom: 100% !important;
  margin-top: 0 !important;
  margin-bottom: 4px !important;
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.3) !important;
}

/* ── Compact Local Task Queue Items ── */
.local-task-item {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 8px !important;
  border: 1px solid var(--border-color);
  border-left: 4px solid #ff3366;
  background-color: var(--bg-input);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.local-task-item-prompt {
  font-size: 0.8rem !important;
  color: var(--text-primary) !important;
  line-height: 1.4 !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-height: 2.8em !important;
  width: 100% !important;
  white-space: normal !important;
}

/* ── Active Server Queue Prompt Clamping ── */
.queue-item-prompt {
  font-size: 0.8rem !important;
  color: var(--text-primary) !important;
  line-height: 1.4 !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-height: 2.8em !important;
  width: 100% !important;
  white-space: normal !important;
  margin-top: 4px !important;
}

/* ── Horizontal Media Thumbnails in Task cards ── */
.local-task-media-row {
  display: flex !important;
  flex-direction: row !important;
  gap: 6px !important;
  flex-wrap: wrap !important;
  margin-top: 4px !important;
  margin-bottom: 4px !important;
  width: 100% !important;
}

.local-task-media-thumbnail {
  position: relative !important;
  width: 48px !important;
  height: 48px !important;
  border-radius: 6px !important;
  overflow: hidden !important;
  border: 1px solid var(--border-strong) !important;
  background: rgba(0, 0, 0, 0.2) !important;
  flex-shrink: 0 !important;
}

.local-task-media-thumbnail img,
.local-task-media-thumbnail video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

.local-task-media-thumbnail .video-badge {
  position: absolute !important;
  bottom: 2px !important;
  right: 2px !important;
  background: rgba(0, 0, 0, 0.75) !important;
  color: #00e676 !important;
  font-size: 8px !important;
  font-weight: 700 !important;
  padding: 1px 3px !important;
  border-radius: 3px !important;
  line-height: 1 !important;
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}




