/* ================================================================
   MEGRA Components Library
   Extracted reusable components — buttons, badges, cards, tables,
   modals, empty states, forms, sidebar enhancements, tabs, alerts.
   Loaded AFTER megra.css (overrides/extends base definitions).
   ================================================================ */


/* ================================================================
   1. BUTTONS — extended variants
   ================================================================ */

/* -- Size variants -- */
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  gap: 4px;
}
.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
  gap: 8px;
}
.btn-block {
  display: flex;
  width: 100%;
  justify-content: center;
}

/* -- Icon button (square, lucide icon centered) -- */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all 100ms ease;
  flex-shrink: 0;
}
.btn-icon:hover {
  background: var(--bg-1);
  color: var(--text);
}
.btn-icon.btn-danger {
  color: var(--fail);
  background: transparent;
  border-color: transparent;
}
.btn-icon.btn-danger:hover {
  background: #fef2f2;
  color: var(--fail);
}
/* ============================================================
 * 24) Sidebar bottom — RapidAPI usage widget
 * ============================================================ */
.sidebar-usage {
  margin-top: auto;
  padding: 14px 14px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-1);
  font-family: 'DM Sans', sans-serif;
}
.sidebar-usage .usage-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.sidebar-usage .usage-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
}
.sidebar-usage .usage-count {
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.sidebar-usage .usage-bar {
  height: 6px;
  background: var(--bg-1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.sidebar-usage .usage-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 300ms ease, background 200ms ease;
}
.sidebar-usage .usage-fill.usage-green { background: #10b981; }
.sidebar-usage .usage-fill.usage-amber { background: #f59e0b; }
.sidebar-usage .usage-fill.usage-red   { background: #ef4444; }
.sidebar-usage .usage-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-family: 'Space Mono', monospace;
}
.sidebar-usage .usage-over {
  color: #ef4444;
  font-weight: 700;
}

/* Sidebar must use flex column so .sidebar-usage margin-top:auto sticks to bottom */
.sidebar {
  display: flex;
  flex-direction: column;
}

.btn-icon.btn-warn {
  color: #b45309;
  background: transparent;
  border-color: transparent;
}
.btn-icon.btn-warn:hover {
  background: #fef3c7;
  border-color: #f59e0b;
}
.btn-icon.btn-success {
  color: var(--ok);
  background: transparent;
  border-color: transparent;
}
.btn-icon.btn-success:hover {
  background: #ecfdf5;
  color: var(--ok);
}
.btn-icon i,
.btn-icon svg {
  width: 18px;
  height: 18px;
}

/* -- Success variant (approve actions) -- */
.btn-success {
  background: var(--ok);
  color: #fff;
  border-color: var(--ok);
}
.btn-success:hover {
  background: #15803d;
}

/* -- Disabled state for all buttons -- */
.btn:disabled,
.btn[disabled],
.btn-icon:disabled,
.btn-icon[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* -- Focus ring (accessibility) -- */
.btn:focus-visible,
.btn-icon:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}


/* ================================================================
   2. BADGES — extended status variants
   ================================================================ */

/* Status-mapped aliases (templates use status-X classes) */
.badge.status-active,
.badge-active {
  background: #ecfdf5;
  color: #059669;
}
.badge.status-paused,
.badge-paused {
  background: #f5f5f4;
  color: #78716c;
}
.badge.status-error,
.badge-error {
  background: #fef2f2;
  color: #dc2626;
}
.badge.status-draft,
.badge.status-pending {
  background: var(--violet-soft);
  color: var(--violet);
}
.badge.status-approved {
  background: #ecfdf5;
  color: #059669;
}
.badge.status-dispatched {
  background: var(--cyan-soft);
  color: var(--cyan);
}
.badge.status-rejected {
  background: #fef2f2;
  color: #dc2626;
}
.badge-info {
  background: #f0f9ff;
  color: #0284c7;
}

/* Badge with dot prefix */
.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}


/* ================================================================
   3. CHIPS (pill, removable)
   ================================================================ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 24px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-1);
  color: var(--text-1);
  border: 1px solid var(--border);
  cursor: default;
  transition: all 100ms ease;
}
.chip:hover {
  background: var(--bg);
  border-color: var(--border-strong);
}
.chip.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.chip .chip-remove {
  display: inline-flex;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 100ms;
}
.chip .chip-remove:hover {
  opacity: 1;
}
.chip .chip-remove svg,
.chip .chip-remove i {
  width: 10px;
  height: 10px;
}


/* ================================================================
   4. KPI CARDS — enhanced with hover lift + shadow
   ================================================================ */

.kpi-card {
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 200ms ease, transform 200ms ease;
}
.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.kpi-value {
  font-family: 'DM Sans', sans-serif;
}

/* Additional KPI color variants used in templates */
.kpi-card.kpi-green::after { background: var(--ok); }
.kpi-card.kpi-pink::after { background: #ec4899; }
.kpi-card.kpi-amber::after { background: #f59e0b; }
.kpi-card.kpi-blue::after { background: #3b82f6; }

/* KPI grid responsive (4-3-2 breakpoints) */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}


/* ================================================================
   5. DENSE TABLE — header bg, hover, status dots, row-actions
   ================================================================ */

.dense-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.dense-table thead {
  position: sticky;
  top: 52px; /* below topbar */
  z-index: 10;
}
.dense-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  font-family: 'Space Mono', monospace;
  background: var(--surface-1);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.dense-table th:first-child { border-radius: var(--r-sm) 0 0 0; }
.dense-table th:last-child { border-radius: 0 var(--r-sm) 0 0; }

.dense-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.dense-table tr:last-child td { border-bottom: none; }
.dense-table tbody tr {
  transition: background 80ms ease;
}
.dense-table tbody tr:hover td {
  background: var(--surface-1);
}

/* Status dot (inline in table cells) */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
.status-dot.status-active,
.status-dot.status-ok { background: var(--ok); }
.status-dot.status-paused,
.status-dot.status-idle { background: var(--idle); }
.status-dot.status-error,
.status-dot.status-fail { background: var(--fail); }
.status-dot.status-warn { background: var(--warn); }
.status-dot.status-running {
  background: var(--lime);
  animation: pulse 1.5s ease-in-out infinite;
}
.status-dot.status-pending { background: var(--violet); }
.status-dot.status-approved { background: var(--ok); }
.status-dot.status-dispatched { background: var(--cyan); }

/* Row actions — show on hover */
.row-actions {
  white-space: nowrap;
  opacity: 0;
  transition: opacity 120ms ease;
}
.row-actions form {
  display: inline-flex;
}
.dense-table tbody tr:hover .row-actions,
.row-actions:focus-within {
  opacity: 1;
}

/* Link cells styled lime */
.dense-table td a {
  color: var(--lime-dim);
  font-weight: 500;
}
.dense-table td a:hover {
  color: var(--lime);
  text-decoration: underline;
}


/* ================================================================
   6. CARD GRID — for carousels, templates, pool
   ================================================================ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 1024px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Individual cards in grid */
.carousel-card,
.template-card,
.meme-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 200ms ease, transform 200ms ease;
}
.carousel-card:hover,
.template-card:hover,
.meme-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-thumb {
  width: 100%;
  min-height: 200px;
  background: var(--bg-1);
  position: relative;
}

.card-meta {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-meta .template-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.card-meta .slide-count {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--text-2);
}
.card-meta .sound-status {
  font-size: 13px;
  color: var(--text-2);
}

.card-actions {
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}


/* ================================================================
   7. MODAL / DIALOG
   ================================================================ */

dialog {
  border: none;
  border-radius: var(--r-lg);
  padding: 0;
  max-width: 480px;
  width: calc(100vw - 48px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.14), 0 4px 16px rgba(0, 0, 0, 0.08);
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop {
  background: rgba(28, 27, 24, 0.45);
  backdrop-filter: blur(4px);
}
dialog[open] {
  animation: dialog-in 200ms ease forwards;
}
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
dialog form,
dialog .dialog-body {
  padding: 24px;
}
dialog h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.modal-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--r-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 100ms ease;
}
.modal-actions button:hover {
  background: var(--surface-1);
}
.modal-actions .btn-primary,
.modal-actions button[type="submit"] {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.modal-actions .btn-primary:hover,
.modal-actions button[type="submit"]:hover {
  background: #333;
}

/* Modal close button (top-right) */
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: all 100ms;
}
.modal-close:hover {
  background: var(--bg-1);
  color: var(--text);
}


/* ================================================================
   8. EMPTY STATE — enhanced
   ================================================================ */

.empty-state {
  text-align: center;
  padding: 64px 24px;
}
.empty-state .empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--lime-soft);
  color: var(--lime-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}
.empty-state .empty-icon i,
.empty-state .empty-icon svg {
  width: 24px;
  height: 24px;
}
.empty-state h4 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.empty-state p {
  font-size: 13px;
  color: var(--text-2);
  max-width: 340px;
  margin: 0 auto 20px;
  line-height: 1.6;
}
.empty-state .btn {
  margin-top: 4px;
}

/* Simple empty text (used in templates as .empty class) */
.empty {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-2);
  font-size: 14px;
}


/* ================================================================
   9. TABS + STATUS-TABS (underline accent)
   ================================================================ */

.status-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.status-tabs .tab,
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  border: none;
  background: none;
  cursor: pointer;
  position: relative;
  transition: color 100ms ease;
  text-decoration: none;
  white-space: nowrap;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--text);
  font-weight: 600;
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--lime);
  border-radius: 1px 1px 0 0;
}

/* Tab count badge */
.tab .tab-count {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  background: var(--bg-1);
  color: var(--text-2);
  padding: 1px 6px;
  border-radius: 3px;
}
.tab.active .tab-count {
  background: var(--lime-soft);
  color: var(--lime-dim);
}


/* ================================================================
   10. ALERTS
   ================================================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.alert-info {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0c4a6e;
}
.alert-success {
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #065f46;
}
.alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #78350f;
}
.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #7f1d1d;
}
.alert i,
.alert svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}


/* ================================================================
   11. TOAST NOTIFICATIONS — positioned top-right, auto-dismiss
   ================================================================ */

.toast-container {
  position: fixed;
  top: 68px; /* below topbar */
  right: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
  pointer-events: none;
}
.toast-container .toast {
  pointer-events: auto;
  box-shadow: var(--shadow-md);
  animation: toast-in 250ms ease forwards;
}
.toast-container .toast.toast-out {
  animation: toast-out 200ms ease forwards;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(24px); }
}

/* Toast close button */
.toast .toast-close {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.toast .toast-close:hover {
  opacity: 1;
}


/* ================================================================
   12. FORMS — labels, spacing, focus ring, validation
   ================================================================ */

/* Form group pattern: label wrapping input */
dialog label,
.form-group label,
form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 4px;
}
dialog label input,
dialog label select,
dialog label textarea,
.form-group input,
.form-group select,
.form-group textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
dialog label input:focus,
dialog label select:focus,
dialog label textarea:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px var(--lime-soft);
}

/* Error state */
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
  border-color: var(--fail);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}
.form-error {
  font-size: 12px;
  color: var(--fail);
  margin-top: -8px;
  margin-bottom: 12px;
}

/* Textarea */
textarea {
  font-family: 'DM Sans', sans-serif;
  resize: vertical;
  min-height: 80px;
}
textarea.mono,
textarea[name*="json"] {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
}

/* Search input with icon space */
.search-input {
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  width: 240px;
  transition: border-color 120ms, box-shadow 120ms;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a8a49b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 16px;
}
.search-input:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px var(--lime-soft);
}
.search-input::placeholder {
  color: var(--text-3);
}

/* Status filter (select) */
.status-filter {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a776e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 28px;
}
.status-filter:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px var(--lime-soft);
}


/* ================================================================
   13. FILTER BAR
   ================================================================ */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}


/* ================================================================
   14. SIDEBAR — active left-bar accent, hover, disabled
   ================================================================ */

/* Active state override — lime left bar instead of full black fill */
.sidebar .nav-item.active {
  background: var(--lime-soft);
  color: var(--text);
  position: relative;
}
.sidebar .nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--lime);
}
.sidebar .nav-item.active i {
  color: var(--lime-dim);
}

/* Hover refinement */
.sidebar .nav-item:not(.active):not(.disabled):hover {
  background: var(--bg);
  color: var(--text);
}
.sidebar .nav-item:not(.active):not(.disabled):hover i {
  color: var(--text-1);
}

/* Disabled */
.sidebar .nav-item.disabled {
  color: var(--text-3);
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.65;
}

/* Sidebar section divider */
.sidebar .nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 4px;
}

/* Sidebar footer */
.sidebar .sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--text-3);
}


/* ================================================================
   15. BREADCRUMB
   ================================================================ */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 20px;
}
.breadcrumb a {
  color: var(--text-2);
  text-decoration: none;
  transition: color 100ms;
}
.breadcrumb a:hover {
  color: var(--text);
}
.breadcrumb .breadcrumb-sep {
  color: var(--text-3);
  font-size: 11px;
}
.breadcrumb .breadcrumb-current {
  color: var(--text);
  font-weight: 600;
}


/* ================================================================
   16. CAROUSEL DETAIL
   ================================================================ */

.carousel-detail {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}
.slide-viewer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.slide-strip {
  display: flex;
  gap: 8px;
  padding: 16px;
  overflow-x: auto;
}
.slide-item {
  flex-shrink: 0;
  text-align: center;
}
.slide-thumb {
  border-radius: var(--r-sm);
  overflow: hidden;
}
.slide-num {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
  display: block;
}

.meta-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.meta-sidebar .card {
  padding: 16px;
}
.meta-sidebar dt {
  font-size: 11px;
  font-family: 'Space Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
  margin-bottom: 2px;
}
.meta-sidebar dd {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 10px;
}
.meta-sidebar dd:last-child {
  margin-bottom: 0;
}

.actions-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}


/* ================================================================
   17. MEME GRID (pool page)
   ================================================================ */

.meme-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
@media (max-width: 1280px) {
  .meme-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 1024px) {
  .meme-grid { grid-template-columns: repeat(3, 1fr); }
}

.meme-card {
  position: relative;
}
.meme-card .thumb-placeholder {
  aspect-ratio: 1;
  background-size: cover;
  background-position: center;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.meme-card .meta {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.meme-card .meta .src {
  font-weight: 500;
  font-size: 12px;
  color: var(--lime-dim);
}
.meme-card .meta .dim {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--text-3);
}
.meme-card .meme-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--lime);
  z-index: 2;
}
.meme-card .hover-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 120ms;
  z-index: 2;
}
.meme-card:hover .hover-actions {
  opacity: 1;
}
.meme-card .hover-actions .btn-icon {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--r-sm);
  backdrop-filter: blur(4px);
}
.meme-card .hover-actions .btn-icon:hover {
  background: #fff;
}


/* ================================================================
   18. BULK ACTION BAR (pool page)
   ================================================================ */

.bulk-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
  border-radius: var(--r-md) var(--r-md) 0 0;
  font-size: 13px;
  z-index: 50;
}
.bulk-bar .bulk-count {
  font-weight: 600;
  color: var(--text);
  margin-right: auto;
}


/* ================================================================
   19. RECENT RUNS section (dashboard)
   ================================================================ */

.recent-runs {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.recent-runs h3 {
  padding: 16px 20px 12px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}


/* ================================================================
   20. UTILITY CLASSES
   ================================================================ */

/* Text utilities */
.text-mono { font-family: 'Space Mono', monospace; }
.text-muted { color: var(--text-2); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Spacing */
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

/* Flex helpers */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

/* Display */
.hidden { display: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Truncate */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}


/* ================================================================
   21. MEGRA BATCH POLISH — accent pills, progress, tabs, forms
   ================================================================ */

/* -- Status pills (replace status-dot + text) -- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 24px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}
.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-pill.status-processing {
  background: #fffbeb;
  color: #b45309;
}
.status-pill.status-processing::before { background: #f59e0b; }
.status-pill.status-ready {
  background: #ecfdf5;
  color: #059669;
}
.status-pill.status-ready::before { background: #16a34a; }
.status-pill.status-claimed {
  background: var(--violet-soft);
  color: #7c3aed;
}
.status-pill.status-claimed::before { background: var(--violet); }
.status-pill.status-failed {
  background: #fef2f2;
  color: #dc2626;
}
.status-pill.status-failed::before { background: #dc2626; }
.status-pill.status-cancelled {
  background: #f5f5f4;
  color: #78716c;
}
.status-pill.status-cancelled::before { background: #a8a29e; }

/* Large pill variant for detail page header */
.status-pill-lg {
  padding: 5px 14px;
  font-size: 13px;
}

/* -- Progress bar (compact, inline in table) -- */
.progress-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-track {
  flex: 1;
  min-width: 60px;
  height: 6px;
  background: var(--bg-1);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 300ms ease;
}
.progress-fill.complete {
  background: var(--ok);
}
.progress-label {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
}

/* Big progress bar for detail page */
.progress-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.progress-hero .progress-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.progress-hero .progress-pct {
  font-family: 'DM Sans', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.progress-hero .progress-counts {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--text-2);
}
.progress-hero .progress-track {
  height: 10px;
  border-radius: 5px;
  min-width: unset;
}
.progress-hero .progress-fill {
  border-radius: 5px;
}

/* -- Accent-themed tabs (upgrade from plain links) -- */
.status-tabs .tab.active::after {
  background: var(--accent);
}
.tab.active .tab-count {
  background: var(--accent-soft);
  color: var(--accent-dim);
}

/* -- Accent-themed primary button -- */
.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-accent:hover {
  background: var(--accent-hover);
}
.btn-accent:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* -- Page header polish for batches -- */
.page-header-batch {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header-batch h1 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.02em;
  border-left: 4px solid var(--accent);
  padding-left: 14px;
}
.page-header-batch .header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* -- Form stack (new.html) -- */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.form-row {
  display: block;
  margin-bottom: 18px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
}
.form-label .text-muted {
  font-weight: 400;
  font-size: 12px;
}
.form-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-input::placeholder {
  color: var(--text-3);
}
/* File input wrapper */
.form-input[type="file"] {
  padding: 8px 12px;
  cursor: pointer;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

/* Drop zone visual hint */
.drop-zone {
  position: relative;
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms, background 150ms;
  background: var(--surface-1);
}
.drop-zone:hover,
.drop-zone:focus-within {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.drop-zone .drop-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
}
.drop-zone .drop-icon i,
.drop-zone .drop-icon svg {
  width: 20px;
  height: 20px;
}
.drop-zone .drop-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}
.drop-zone .drop-text strong {
  color: var(--accent);
}
.drop-zone input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Hover overlay for reel cards in batch detail */
.hover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 50%, rgba(0, 0, 0, 0.7));
  opacity: 0;
  transition: opacity 150ms ease;
  display: flex;
  align-items: flex-end;
  padding: 10px;
  border-radius: var(--r-md);
  pointer-events: none;
}
.hover-overlay a, .hover-overlay button {
  pointer-events: auto;
}
.meme-card:hover .hover-overlay {
  opacity: 1;
}

/* Reel lightbox modal — click on card to expand */
.reel-card-clickable {
  cursor: zoom-in;
}
.reel-lightbox[hidden] {
  display: none;
}
.reel-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  backdrop-filter: blur(4px);
}
.reel-lightbox video {
  max-width: min(calc(90vh * 9 / 16), 92vw);
  max-height: 90vh;
  width: auto;
  height: 90vh;
  aspect-ratio: 9 / 16;
  background: #000;
  border-radius: 12px;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
  object-fit: contain;
}
.reel-lightbox .lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.92);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1001;
  transition: background 120ms;
}
.reel-lightbox .lightbox-close:hover {
  background: #fff;
}
.reel-lightbox .lightbox-meta {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.85);
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 14px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}
.overlay-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.overlay-meta span {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.9);
}

/* KPI card accent variant */
.kpi-card.kpi-accent::after { background: var(--accent); }

/* Responsive: mobile form full-width submit */
@media (max-width: 768px) {
  .form-stack { max-width: 100% !important; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }
  .page-header-batch h1 { font-size: 22px; }
}


/* ================================================================
   22. BATCH NEW — card-grouped form + live preview sidebar
   ================================================================ */

/* -- Two-column layout: cards left, preview right -- */
.batch-form-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
  align-items: start;
  max-width: 900px;
}

/* -- Form card -- */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  transition: box-shadow 200ms ease, border-color 200ms ease;
}
.form-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.form-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 22px 0;
}
.form-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.form-card-icon i,
.form-card-icon svg {
  width: 18px;
  height: 18px;
}
.form-card-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 2px;
}
.form-card-desc {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.4;
}

.form-card-body {
  padding: 16px 22px 22px;
}

/* -- Field (single input group inside card) -- */
.field {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  margin-bottom: 6px;
  font-family: 'Space Mono', monospace;
}
.field-optional {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-3);
  background: var(--bg-1);
  border-radius: 3px;
  padding: 1px 6px;
  margin-left: 6px;
  font-family: 'DM Sans', sans-serif;
  vertical-align: middle;
}
.field-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-1);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.field-input:hover {
  border-color: var(--border-strong);
}
.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.field-input::placeholder {
  color: var(--text-3);
}
/* Number input: slightly narrower in card context */
.field-input[type="number"] {
  -moz-appearance: textfield;
}
.field-input[type="number"]::-webkit-outer-spin-button,
.field-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field-hint {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 6px;
  line-height: 1.4;
}

/* Two-column row inside a card (qty + archetype) */
.field-row-2col {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
}

/* -- Drop zone enhancements for batch new -- */
.drop-zone-active {
  border-color: var(--accent) !important;
  background: var(--accent-soft) !important;
}
.drop-meta {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 6px;
  min-height: 16px;
}

/* -- Preview / summary card (right column, sticky) -- */
.batch-preview-col {
  position: sticky;
  top: 80px; /* topbar 52px + 28px content padding */
}
.batch-preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.batch-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.batch-preview-header i,
.batch-preview-header svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.batch-preview-body {
  padding: 16px 18px;
}

/* Definition list inside preview */
.preview-dl {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.preview-dl-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.preview-dl-row:last-child {
  border-bottom: none;
}
.preview-dl dt {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}
.preview-dl dd {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-preview-footer {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-1);
}
.preview-estimate {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 14px;
}
.preview-estimate i,
.preview-estimate svg {
  width: 14px;
  height: 14px;
  color: var(--text-3);
}

/* Mobile submit (hidden on desktop, visible on mobile) */
.batch-form-submit-mobile {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

/* ---- Responsive: batch form ---- */
@media (max-width: 860px) {
  .batch-form-layout {
    grid-template-columns: 1fr;
    max-width: 100%;
  }
  .batch-preview-col {
    position: static;
    order: -1; /* summary on top on mobile */
  }
  .batch-preview-card {
    margin-bottom: 8px;
  }
  /* Hide desktop submit inside preview, show mobile submit */
  .batch-preview-footer .btn,
  .batch-preview-footer a.btn {
    display: none;
  }
  .batch-form-submit-mobile {
    display: flex;
  }
  .field-row-2col {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 480px) {
  .form-card-header {
    padding: 14px 16px 0;
  }
  .form-card-body {
    padding: 14px 16px 18px;
  }
  .form-card-icon {
    width: 32px;
    height: 32px;
  }
  .batch-preview-body {
    padding: 12px 14px;
  }
}

/* ============================================================
 * 23) /batches/new — generous redesign (replaces section 22 usage)
 *     Single-column, hero-style, wide typography, no sticky preview
 * ============================================================ */

.new-batch-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 24px 80px;
}

/* ---- Hero header ---- */
.new-batch-hero {
  margin-bottom: 56px;
}
.new-batch-hero .hero-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  margin-bottom: 28px;
  transition: color 150ms ease;
}
.new-batch-hero .hero-back:hover {
  color: var(--accent);
}
.new-batch-hero .hero-back i,
.new-batch-hero .hero-back svg {
  width: 14px;
  height: 14px;
}
.new-batch-hero h1 {
  font-family: 'Syne', sans-serif;
  font-size: 36px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 12px;
}
.new-batch-hero .hero-sub {
  font-family: 'DM Sans', sans-serif;
  font-size: 17px;
  line-height: 1.5;
  color: var(--text-2);
  margin: 0;
  max-width: 560px;
}

/* ---- Form layout ---- */
.new-batch-form {
  display: flex;
  flex-direction: column;
  gap: 48px;
}

/* ---- Section (one per step) ---- */
.bx-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 36px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02), 0 4px 12px rgba(0, 0, 0, 0.03);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.bx-section:hover {
  border-color: var(--border-strong);
}
.bx-section-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}
.bx-step {
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 7px 11px;
  flex-shrink: 0;
  line-height: 1;
}
.bx-title {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 4px;
}
.bx-desc {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-2);
  margin: 0;
}

/* ---- Field ---- */
.bx-field {
  display: flex;
  flex-direction: column;
}
.bx-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bx-pill-optional {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-3);
  background: var(--bg-1);
  border-radius: 999px;
  padding: 3px 10px;
}
.bx-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.bx-input--lg {
  padding: 16px 18px;
  font-size: 17px;
  min-height: 56px;
}
.bx-input::placeholder {
  color: var(--text-3);
}
.bx-input:hover {
  border-color: var(--border-strong);
}
.bx-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.bx-input[type="number"] {
  -moz-appearance: textfield;
}
.bx-input[type="number"]::-webkit-outer-spin-button,
.bx-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.bx-hint {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text-3);
  margin-top: 8px;
}

/* ---- 2-col field grid ---- */
.bx-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 20px;
}

/* ---- Drop zone (audio) — big + inviting ---- */
.bx-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 32px;
  background: var(--surface-1);
  border: 2px dashed var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease, transform 100ms ease;
}
.bx-drop:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.bx-drop--dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.005);
}
.bx-drop--has-file {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
}
.bx-drop-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--surface);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.bx-drop-icon i,
.bx-drop-icon svg {
  width: 26px;
  height: 26px;
}
.bx-drop-headline {
  font-family: 'DM Sans', sans-serif;
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}
.bx-drop-headline strong {
  font-weight: 700;
  color: var(--accent);
}
.bx-drop-sub {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text-2);
  margin-top: 6px;
}
.bx-drop-meta {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 14px;
  min-height: 14px;
}
.bx-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ---- Footer / submit row ---- */
.bx-footer {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 24px 8px 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.bx-summary {
  flex: 1;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--text-2);
}
.bx-summary strong {
  color: var(--text);
  font-weight: 700;
}
.bx-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* ---- Submit disabled state ---- */
.btn.btn-accent:disabled,
.btn.btn-accent[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---- Mobile ---- */
@media (max-width: 720px) {
  .new-batch-page {
    padding: 8px 16px 64px;
  }
  .new-batch-hero {
    margin-bottom: 36px;
  }
  .new-batch-hero h1 {
    font-size: 28px;
  }
  .new-batch-hero .hero-sub {
    font-size: 15px;
  }
  .new-batch-form {
    gap: 28px;
  }
  .bx-section {
    padding: 24px 20px;
    border-radius: 14px;
  }
  .bx-section-head {
    margin-bottom: 20px;
  }
  .bx-title {
    font-size: 19px;
  }
  .bx-grid-2 {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .bx-drop {
    padding: 36px 20px;
  }
  .bx-drop-icon {
    width: 48px;
    height: 48px;
  }
  .bx-drop-headline {
    font-size: 16px;
  }
  .bx-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  .bx-summary {
    text-align: center;
  }
  .bx-actions {
    flex-direction: column-reverse;
  }
  .bx-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ================================================================
   TAG SYSTEM (batch list, batch create form)
   ================================================================ */

.tag-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #111;
  letter-spacing: 0.02em;
  margin: 0 4px 4px 0;
  line-height: 1.5;
}

.tag-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
}
.tag-picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  align-items: center;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #111;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 120ms ease;
  background: var(--bg-2);
}
.tag-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.tag-chip.selected {
  border-color: #111;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6) inset;
}
.tag-chip-dot {
  display: none;
}
.tag-chip.selected .tag-chip-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #111;
}

.tag-create {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}
.tag-color-swatches {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tag-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 120ms;
}
.tag-color-swatch:hover {
  transform: scale(1.15);
}
.tag-color-swatch.active {
  border-color: #111;
  box-shadow: 0 0 0 2px #fff inset;
}
#tagColorCustom {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
}

/* ================================================================
   REEL CARD: checkbox in top-left
   ================================================================ */

.reel-select-label {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms ease;
}
.meme-card:hover .reel-select-label,
.reel-select-label:has(input:checked),
.meme-card:has(.reel-check:checked) .reel-select-label {
  opacity: 1;
}
.reel-select-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--lime, #A3FF6B);
  cursor: pointer;
  margin: 0;
}
.meme-card:has(.reel-check:checked) {
  outline: 3px solid var(--lime, #A3FF6B);
  outline-offset: -3px;
}

/* ================================================================
   AUDIO PREVIEW (batch create form)
   ================================================================ */

.audio-preview {
  margin-top: 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
}
.audio-preview-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.audio-preview-head i,
.audio-preview-head svg {
  color: var(--lime, #A3FF6B);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.audio-preview-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-preview-stats {
  font-size: 11px;
  color: var(--text-2);
  margin-left: auto;
}
.audio-preview audio {
  display: block;
  width: 100%;
  margin-top: 8px;
  height: 36px;
}

/* ================================================================
   25. Render Preset Studio (/batches/new)
   ================================================================ */

.render-preset-studio {
  overflow: visible;
  width: min(1180px, calc(100vw - 320px));
  margin-left: 50%;
  transform: translateX(-50%);
}
.rps-status {
  margin: -4px 0 18px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  background: var(--surface-1);
  color: var(--text-2);
  font-size: 13px;
}
.rps-status.error {
  border-color: rgba(220, 38, 38, .24);
  background: #fef2f2;
  color: #991b1b;
}
.rps-status.ok {
  border-color: rgba(22, 163, 74, .2);
  background: #ecfdf5;
  color: #166534;
}
.rps-layout {
  display: grid;
  grid-template-columns: minmax(170px, .62fr) minmax(360px, 1.35fr) minmax(220px, .72fr);
  gap: 18px;
  align-items: start;
}
.rps-column {
  min-width: 0;
}
.rps-column--library {
  border-right: 1px solid var(--border);
  padding-right: 18px;
}
.rps-column--preview {
  position: sticky;
  top: 70px;
  border-left: 1px solid var(--border);
  padding-left: 18px;
}
.rps-subhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.rps-subhead strong {
  display: block;
  font-size: 15px;
  color: var(--text);
}
.rps-eyebrow {
  display: block;
  margin-bottom: 2px;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent-dim);
}
.rps-editor-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.rps-preset-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rps-preset {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 11px 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease, transform 120ms ease;
}
.rps-preset:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.rps-preset.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.rps-preset-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.rps-preset-main strong {
  font-size: 13px;
  color: var(--text);
}
.rps-preset-main small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--text-3);
}
.rps-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.rps-badges em {
  font-style: normal;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--text-2);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 6px;
}
.rps-empty,
.rps-selected-summary {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-2);
}
.rps-preview {
  margin-top: 0;
}
.rps-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.rps-preview-head strong {
  font-size: 14px;
}
.rps-preview-meta {
  color: var(--text-3);
  font-size: 11px;
}
.rps-preview-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.rps-preview-canvas {
  --rps-bg-a: #f6f5f2;
  --rps-bg-b: #e9dfd7;
  --rps-frame-w: 83%;
  --rps-frame-h: 66%;
  --rps-border: 3px;
  --rps-border-color: #fff;
  --rps-shadow: 0 18px 42px rgba(16, 16, 16, .16);
  --rps-fit: contain;
  --rps-filter: contrast(1.05) saturate(1.05);
  --rps-grain: .16;
  position: relative;
  width: min(100%, 248px);
  margin: 0 auto;
  aspect-ratio: 9 / 16;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--rps-bg-a), var(--rps-bg-b));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.rps-preview-canvas.is-solid-bg {
  background: var(--rps-bg-a);
}
.rps-preview-bg {
  position: absolute;
  inset: -18px;
  opacity: 0;
  transform: scale(1.08);
  filter: blur(16px) saturate(1.15);
}
.rps-preview-canvas.is-blur-bg .rps-preview-bg {
  opacity: .55;
}
.rps-preview-bg img,
.rps-preview-bg video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rps-preview-canvas::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--rps-grain);
  background-image:
    repeating-radial-gradient(circle at 20% 30%, rgba(0,0,0,.12) 0 1px, transparent 1px 3px),
    radial-gradient(circle at 50% 50%, transparent 54%, rgba(0,0,0,.32) 100%);
  mix-blend-mode: multiply;
}
.rps-preview-frame {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: var(--rps-frame-w);
  height: var(--rps-frame-h);
  transform: translate(-50%, -50%);
  border: var(--rps-border) solid var(--rps-border-color);
  background: rgba(255, 255, 255, .22);
  box-shadow: var(--rps-shadow);
  overflow: hidden;
}
.rps-preview-frame img,
.rps-preview-frame video {
  width: 100%;
  height: 100%;
  object-fit: var(--rps-fit);
  filter: var(--rps-filter);
  background: #101010;
}
.rps-preview-canvas.is-motion .rps-preview-frame img {
  animation: rps-kenburns 7s ease-in-out infinite alternate;
}
@keyframes rps-kenburns {
  from { transform: scale(1); }
  to { transform: scale(1.04); }
}
.rps-preview-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--text-2);
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  text-align: center;
  padding: 16px;
}
.rps-form-grid {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 14px;
}
.rps-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.rps-field--wide,
.rps-slider-grid {
  grid-column: 1 / -1;
}
.rps-field > span,
.rps-swatches span,
.rps-slider-grid span {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
}
.rps-field .bx-input {
  min-height: 42px;
  padding: 10px 12px;
  font-size: 14px;
}
.rps-segment {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-1);
}
.rps-segment button {
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  padding: 9px 8px;
  color: var(--text-2);
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  transition: background 120ms ease, color 120ms ease;
}
.rps-segment button:last-child {
  border-right: 0;
}
.rps-segment button:hover,
.rps-segment button.active {
  background: var(--accent);
  color: #fff;
}
.rps-check-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.rps-check-grid label,
.rps-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
  padding: 9px 10px;
  font-size: 12px;
  color: var(--text-1);
}
.rps-check-grid input,
.rps-toggle input {
  accent-color: var(--accent);
}
.rps-swatches {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.rps-swatches label {
  display: grid;
  gap: 6px;
}
.rps-swatches input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
.rps-slider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.rps-slider-grid label {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 20px;
  align-items: center;
  gap: 3px 10px;
  min-width: 0;
  min-height: 0;
  padding: 6px 8px 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-1);
}
.rps-slider-grid input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: ew-resize;
  touch-action: pan-y;
  grid-column: 1 / -1;
}
.rps-slider-grid input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff, #f3f1ed);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .08);
}
.rps-slider-grid input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .22);
}
.rps-slider-grid input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff, #f3f1ed);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .08);
}
.rps-slider-grid input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .22);
  cursor: ew-resize;
}
.rps-slider-grid input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.rps-slider-grid b {
  grid-column: 2;
  grid-row: 1;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--text-2);
  text-align: right;
}
.rps-toggle {
  align-items: flex-start;
  cursor: pointer;
}
.rps-toggle strong {
  display: block;
  font-size: 13px;
  color: var(--text);
}
.rps-toggle small {
  display: block;
  margin-top: 2px;
  color: var(--text-2);
  line-height: 1.35;
}

@media (max-width: 1320px) {
  .render-preset-studio {
    width: 100%;
    margin-left: 0;
    transform: none;
  }
  .rps-layout {
    grid-template-columns: minmax(0, 1fr) minmax(220px, .58fr);
  }
  .rps-column--library {
    grid-column: 1 / -1;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 22px;
  }
  .rps-column--preview {
    top: 70px;
  }
}
@media (max-width: 980px) {
  .rps-layout {
    grid-template-columns: 1fr;
  }
  .rps-column--preview {
    position: static;
    border-left: 0;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 18px;
  }
  .rps-preview-canvas {
    width: min(100%, 320px);
  }
}
@media (max-width: 640px) {
  .rps-subhead {
    flex-direction: column;
  }
  .rps-editor-actions,
  .rps-editor-actions .btn {
    width: 100%;
  }
  .rps-editor-actions .btn {
    justify-content: center;
  }
  .rps-form-grid,
  .rps-swatches,
  .rps-check-grid {
    grid-template-columns: 1fr;
  }
  .rps-slider-grid {
    grid-template-columns: 1fr;
  }
  .rps-slider-grid label {
    grid-template-columns: 1fr auto;
  }
}
