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

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.1);
  --primary-glow: rgba(99, 102, 241, 0.25);
  --accent: #06b6d4;
  --accent-hover: #0891b2;
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.1);
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.08);
  --warning: #8b5cf6;
  --warning-light: rgba(139, 92, 246, 0.1);

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --bg: #f8fafc;
  --bg-card: #ffffff;

  /* Sidebar palette — deep navy with subtle warmth */
  --bg-sidebar: #0c1222;
  --bg-sidebar-surface: rgba(255, 255, 255, 0.04);
  --bg-sidebar-hover: rgba(255, 255, 255, 0.07);
  --bg-sidebar-active: rgba(99, 102, 241, 0.12);
  --sidebar-text: #cbd5e1;
  --sidebar-text-bright: #f1f5f9;
  --sidebar-text-muted: #475569;
  --sidebar-border: rgba(255, 255, 255, 0.06);

  --white: #ffffff;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 10px -2px rgba(0, 0, 0, 0.05);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.12s ease;
  --transition-spring: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-base: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
}

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

/* ─── Focus ─── */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius);
}

*:focus:not(:focus-visible) {
  outline: 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: 0;
}

/* ─── App Layout ─── */
.app {
  display: flex;
  height: 100vh;
}

/* ═══════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════ */
.sidebar {
  width: 440px;
  min-width: 440px;
  background: var(--bg-sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  position: relative;
  z-index: 10;
}

/* Subtle gradient overlay on sidebar */
.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 200px;
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.06) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Sidebar Header ─── */
.sidebar-header {
  padding: 22px 24px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  position: relative;
  z-index: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.sidebar-header h1 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.sidebar-header .subtitle {
  font-size: 0.7rem;
  color: var(--sidebar-text-muted);
  margin-top: 1px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ─── Sidebar Scroll ─── */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px 24px;
  position: relative;
  z-index: 1;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 5px;
}

.sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ═══════════════════════════════════════════
   PANELS (Collapsible)
   ═══════════════════════════════════════════ */
.panel {
  margin-bottom: 4px;
  border-radius: var(--radius-lg);
  background: var(--bg-sidebar-surface);
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition);
  overflow: hidden;
}

.panel:hover {
  background: var(--bg-sidebar-hover);
  border-color: var(--sidebar-border);
}

/* Panel Header (clickable toggle) */
.panel-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.panel-header:hover {
  color: var(--sidebar-text-bright);
}

.panel-header:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-icon {
  color: var(--sidebar-text-muted);
  flex-shrink: 0;
  transition: color var(--transition);
}

.panel:hover .panel-icon {
  color: var(--primary);
}

.panel-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-text-muted);
  transition: color var(--transition);
}

.panel-header:hover .panel-title {
  color: var(--sidebar-text);
}

.panel-chevron {
  color: var(--sidebar-text-muted);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color var(--transition);
  flex-shrink: 0;
}

.panel-header[aria-expanded="false"] .panel-chevron {
  transform: rotate(-90deg);
}

.panel-header:hover .panel-chevron {
  color: var(--sidebar-text);
}

/* Panel Body */
.panel-body {
  padding: 0 16px 16px;
  animation: panelOpen 0.2s ease;
}

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

/* ─── Search Input ─── */
.search-wrap {
  position: relative;
  margin-bottom: 10px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sidebar-text-muted);
  pointer-events: none;
  transition: color var(--transition);
}

.search-wrap:focus-within .search-icon {
  color: var(--primary);
}

.search-input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  color: var(--sidebar-text-bright);
  font-size: 0.8rem;
  transition: var(--transition);
  font-family: inherit;
}

.search-input:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

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

/* ═══════════════════════════════════════════
   TEMPLATE GRID
   ═══════════════════════════════════════════ */
.template-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}

.template-grid::-webkit-scrollbar {
  width: 3px;
}

.template-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
}

.template-item {
  position: relative;
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color var(--transition), transform var(--transition-fast), box-shadow var(--transition);
  aspect-ratio: 9/16;
}

.template-item:hover {
  border-color: rgba(255, 255, 255, 0.25);
  transform: scale(1.03);
}

.template-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.template-item.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), 0 0 12px rgba(99, 102, 241, 0.35);
}

.template-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.template-item .template-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.55rem;
  padding: 14px 4px 3px;
  text-align: center;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-item .template-check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.template-item .template-check::after {
  content: '';
  width: 6px;
  height: 3px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg);
  margin-top: -1px;
}

.template-item.selected .template-check {
  display: flex;
}

/* ═══════════════════════════════════════════
   CONTROLS
   ═══════════════════════════════════════════ */
.control-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: 10px;
}

.control-row:last-child {
  margin-bottom: 0;
}

.control-label {
  font-size: 0.8rem;
  color: var(--sidebar-text);
  white-space: nowrap;
  min-width: 90px;
  font-weight: 500;
}

.value-badge {
  display: inline-block;
  background: var(--primary-glow);
  color: #a5b4fc;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--sidebar-text);
  width: 100%;
  padding: 2px 0;
  transition: color var(--transition);
}

.toggle-label:hover {
  color: var(--sidebar-text-bright);
}

.toggle-label input {
  display: none;
}

.toggle-switch {
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--white);
  border-radius: 50%;
  transition: transform var(--transition-spring);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-label input:checked + .toggle-switch {
  background: var(--primary);
}

.toggle-label input:checked + .toggle-switch::after {
  transform: translateX(16px);
}

/* Select */
.select-input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  color: var(--sidebar-text-bright);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.select-input:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.select-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.select-input option {
  background: var(--bg-sidebar);
  color: var(--sidebar-text);
}

.select-sm {
  flex: 1;
}

/* Text input (sidebar) */
.text-input {
  flex: 1;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  color: var(--sidebar-text-bright);
  font-size: 0.8rem;
  transition: var(--transition);
  font-family: inherit;
}

.text-input:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.text-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

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

.text-sm {
  font-size: 0.75rem;
}

/* Slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  flex: 1;
  transition: background var(--transition);
}

.slider:hover {
  background: rgba(255, 255, 255, 0.15);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  transition: transform var(--transition-spring), box-shadow var(--transition);
  box-shadow: 0 1px 4px rgba(99, 102, 241, 0.3);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.5);
}

.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
}

/* Color inputs */
.color-row {
  display: flex;
  gap: 12px;
}

.color-field {
  flex: 1;
}

.color-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 5px 10px 5px 5px;
  transition: border-color var(--transition);
}

.color-input-wrap:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.color-input {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  background: none;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
}

.color-hex {
  font-size: 0.7rem;
  color: var(--sidebar-text-muted);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-weight: 500;
}

/* CLI */
.cli-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.cli-textarea {
  flex: 1;
  width: 100%;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  color: #a5b4fc;
  font-size: 0.7rem;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  resize: none;
  line-height: 1.6;
}

.cli-textarea:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.12);
}

/* ═══════════════════════════════════════════
   AUDIO GRID (Sidebar)
   ═══════════════════════════════════════════ */
.sidebar-audio-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}

.sidebar-audio-grid::-webkit-scrollbar {
  width: 3px;
}

.sidebar-audio-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
}

.audio-item {
  position: relative;
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1.5px solid transparent;
  transition: all var(--transition);
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.audio-item:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
}

.audio-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.audio-item.selected {
  border-color: var(--primary);
  background: var(--bg-sidebar-active);
}

.audio-item .audio-icon {
  font-size: 0.85rem;
  opacity: 0.7;
  flex-shrink: 0;
}

.audio-item .audio-name {
  font-size: 0.75rem;
  color: var(--sidebar-text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  line-height: 1.3;
}

.audio-item.selected .audio-name {
  color: var(--sidebar-text-bright);
}

.audio-item .audio-play-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--sidebar-text);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  padding: 0;
  flex-shrink: 0;
}

.audio-item .audio-play-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  transform: scale(1.1);
}

.audio-item .audio-check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  background: var(--primary);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}

.audio-item .audio-check::after {
  content: '';
  width: 5px;
  height: 3px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg);
  margin-top: -1px;
}

.audio-item.selected .audio-check {
  display: flex;
}

.audio-item-none {
  opacity: 0.5;
}

.audio-item-none:hover {
  opacity: 0.75;
}

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

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

.btn-xs {
  padding: 5px 10px;
  font-size: 0.7rem;
  border-radius: 6px;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 13px 28px;
  font-size: 0.9rem;
  border-radius: var(--radius-lg);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover), #6366f1);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}

.btn-ghost {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 2px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #22d3ee);
  color: var(--white);
  box-shadow: 0 2px 6px rgba(6, 182, 212, 0.25);
}

.btn-accent:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--primary);
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-glass {
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-glass:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  color: var(--white);
}

/* Sidebar outline buttons */
.sidebar .btn-outline {
  color: var(--sidebar-text);
  border-color: rgba(255, 255, 255, 0.15);
}

.sidebar .btn-outline:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.25);
  transform: none;
  box-shadow: none;
}

.btn-danger-outline {
  background: transparent;
  color: #f87171;
  border: 1.5px solid rgba(239, 68, 68, 0.25);
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-light);
  border-color: var(--danger);
}

/* ═══════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: var(--space-xl) var(--space-2xl);
  background: var(--bg);
}

/* Subtle pattern on main bg */
.main-content::before {
  content: '';
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 440px;
  background: radial-gradient(circle at 80% 20%, rgba(99, 102, 241, 0.03) 0%, transparent 50%),
              radial-gradient(circle at 20% 80%, rgba(6, 182, 212, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.main-content > * {
  position: relative;
  z-index: 1;
}

/* ─── Editor ─── */
.editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.editor-field {
  display: flex;
  flex-direction: column;
}

.editor-field-grow {
  flex: 1;
}

.editor-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.editor-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.meta-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.editor-input {
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  transition: var(--transition);
  font-family: inherit;
  background: var(--bg-card);
}

.editor-input:hover {
  border-color: #cbd5e1;
}

.editor-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.editor-textarea {
  flex: 1;
  min-height: 280px;
  padding: 16px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.7;
  resize: vertical;
  transition: var(--transition);
  font-family: inherit;
  background: var(--bg-card);
}

.editor-textarea:hover {
  border-color: #cbd5e1;
}

.editor-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.editor-textarea::placeholder {
  color: var(--text-muted);
}

/* ─── Output Format — Compact Radio Row ─── */
.format-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}

.format-row-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 4px;
}

.format-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition);
}

.format-radio:hover {
  color: var(--text);
}

.format-radio input {
  display: none;
}

.format-radio-mark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-radius: 50%;
  position: relative;
  transition: all var(--transition);
  flex-shrink: 0;
}

.format-radio-mark::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.format-radio input:checked + .format-radio-mark {
  border-color: var(--primary);
}

.format-radio input:checked + .format-radio-mark::after {
  transform: translate(-50%, -50%) scale(1);
}

.format-radio input:checked ~ {
  color: var(--text);
}

.format-duration {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.duration-input-sm {
  width: 60px;
  padding: 5px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  font-family: inherit;
  background: var(--bg);
}

.duration-input-sm:focus {
  outline: none;
  border-color: var(--primary);
}

.duration-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.duration-input {
  width: 72px;
  padding: 8px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  font-family: inherit;
  background: var(--bg-card);
}

.duration-input:focus {
  outline: none;
  border-color: var(--primary);
}

.duration-unit {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── Action Bar ─── */
.action-bar {
  display: flex;
  gap: var(--space-md);
}

.action-bar .btn-lg {
  flex: 1;
}

/* ─── Storage Upload Status ─── */
.storage-upload-status {
  margin: 0 0 12px 0;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
}

.storage-upload-status.uploading {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.storage-upload-status.upload-success {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border-color: #10b981;
}

.storage-upload-status.upload-error {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: #ef4444;
}

.storage-upload-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.storage-upload-summary .upload-file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ─── Content Filter Rules ─── */
.content-filter-rules {
  margin-top: 8px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
}

.filter-rules-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.filter-rules-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.filter-rules-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.filter-rule-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-rule-row input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.filter-rule-row input:focus {
  border-color: var(--primary);
}

.filter-rule-arrow {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.filter-rule-del {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1;
}

.filter-rule-del:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* ─── Live Preview ─── */
.live-preview-panel {
  margin-top: var(--space-lg);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: slideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.live-preview-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-hover);
}

.live-preview-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: #ef4444;
  color: #fff;
  animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.live-preview-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.live-preview-container {
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #0a0a0a;
}

.live-preview-frame {
  width: 270px;
  height: 480px;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  background: #1a1a2e;
}

.live-preview-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.live-preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 1080px;
  height: 1920px;
  transform: scale(0.25);
  transform-origin: top left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

.live-preview-text-title {
  font-size: 72px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 80px;
  text-shadow: 3px 3px 10px rgba(0, 0, 0, 0.3);
  line-height: 1.2;
  color: #ffffff;
  word-wrap: break-word;
  width: 100%;
}

.live-preview-text-title:empty {
  display: none;
  margin-bottom: 0;
}

.live-preview-text-content {
  font-size: 46px;
  font-weight: 400;
  text-align: center;
  line-height: 1.7;
  max-height: 1400px;
  overflow: hidden;
  word-wrap: break-word;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
  color: #ffffff;
  width: 100%;
}

.live-preview-text-content p {
  margin: 0 0 30px 0;
}

.live-preview-text-content p:last-child {
  margin-bottom: 0;
}

.live-preview-text-content strong {
  font-weight: 900;
}

.live-preview-footer {
  position: absolute;
  bottom: 60px;
  font-size: 32px;
  opacity: 0.85;
  font-weight: 500;
  color: #ffffff;
}

/* ─── Status ─── */
.status-bar {
  padding: 14px var(--space-lg);
  border-radius: var(--radius-lg);
  margin-top: var(--space-lg);
  font-size: 0.85rem;
  font-weight: 500;
  animation: slideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 10px;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.status-bar.loading {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.15);
}

.status-bar.success {
  background: var(--success-light);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.status-bar.error {
  background: var(--danger-light);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.15);
}

.hidden {
  display: none !important;
}

/* ─── Output Sections ─── */
.output-section {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 2px solid var(--border-light);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.section-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* Video Result */
.video-result {
  margin-bottom: 24px;
}

.video-player-wrap {
  background: #000;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  margin: 0 auto;
}

.video-player {
  width: 100%;
  display: block;
  max-height: 70vh;
}

.video-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-base);
  margin-top: var(--space-base);
}

/* Image Results */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-base);
  margin-bottom: var(--space-base);
}

.result-image {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid var(--border-light);
}

.result-image:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.result-image img {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 9/16;
  object-fit: cover;
}

.result-image-info {
  padding: 12px;
  text-align: center;
}

.result-image-info .page-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.result-image-info .download-btn {
  width: 100%;
  padding: 7px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: var(--transition);
  font-family: inherit;
}

.result-image-info .download-btn:hover {
  background: var(--primary-hover);
}

.image-actions {
  text-align: center;
}

/* ═══════════════════════════════════════════
   MODE TOGGLE
   ═══════════════════════════════════════════ */
.mode-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.mode-toggle-bar .format-row {
  margin: 0;
  border: none;
  padding: 0;
  background: none;
  box-shadow: none;
}

.mode-toggle {
  display: inline-flex;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3px;
  gap: 3px;
  box-shadow: var(--shadow-xs);
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

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

.mode-btn.active {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.mode-btn.active svg {
  stroke: var(--white);
}

.mode-btn[data-mode="production"].active {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.35);
}

.mode-btn[data-mode="storage-crm"].active {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

/* ═══════════════════════════════════════════
   PRODUCTION — Confirm Modal
   ═══════════════════════════════════════════ */
.prod-confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: prodModalFadeIn 0.2s ease;
}

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

@keyframes prodModalSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.prod-confirm-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
  width: 440px;
  max-width: 90vw;
  max-height: 80vh;
  overflow: hidden;
  animation: prodModalSlideUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.prod-confirm-header {
  text-align: center;
  padding: 28px 28px 16px;
}

.prod-confirm-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(124, 58, 237, 0.08));
  color: #7c3aed;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.prod-confirm-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.prod-confirm-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.prod-confirm-body {
  padding: 0 28px 20px;
}

.prod-confirm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 6px;
  background: var(--bg);
  border: 1px solid var(--border-light);
}

.prod-confirm-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.prod-confirm-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}

.prod-confirm-presets {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  max-height: 120px;
  overflow-y: auto;
}

.prod-confirm-presets-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.prod-confirm-preset-tag {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(139, 92, 246, 0.08);
  color: #7c3aed;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  margin: 2px 3px 2px 0;
}

.prod-confirm-actions {
  display: flex;
  gap: 10px;
  padding: 16px 28px 24px;
  justify-content: flex-end;
}

.prod-confirm-actions .btn {
  padding: 8px 20px;
}

/* ═══════════════════════════════════════════
   STORAGE CRM — Login Overlay
   ═══════════════════════════════════════════ */
.storage-login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(12, 18, 34, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.storage-login-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05);
  text-align: center;
}

.storage-login-icon {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin: 0 auto 20px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.storage-login-card h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.storage-login-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.storage-login-field {
  text-align: left;
  margin-bottom: 16px;
}

.storage-login-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.storage-login-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text);
  font-family: inherit;
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.storage-login-input:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.storage-login-input::placeholder {
  color: var(--text-muted);
}

.storage-login-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  margin-bottom: 16px;
  text-align: left;
}

.storage-login-submit {
  width: 100%;
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.storage-login-submit:hover {
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.45);
}

/* ═══════════════════════════════════════════
   STORAGE CRM — Sidebar
   ═══════════════════════════════════════════ */
.storage-sidebar {
  width: 340px;
  min-width: 340px;
}

.storage-user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.08);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.storage-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sidebar-text);
  font-size: 0.8rem;
  min-width: 0;
}

.storage-user-email {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.storage-logout-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--sidebar-text-muted);
  border-radius: var(--radius);
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all var(--transition);
}

.storage-logout-btn:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

.storage-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-text-muted);
}

.storage-refresh-btn {
  background: none;
  border: none;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  transition: all var(--transition);
}

.storage-refresh-btn:hover {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}

.storage-account-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.storage-account-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  border: 1.5px solid transparent;
  background: rgba(255, 255, 255, 0.03);
}

.storage-account-item:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.1);
}

.storage-account-item.active {
  background: rgba(245, 158, 11, 0.1);
  border-color: #f59e0b;
}

.storage-account-icon {
  width: 32px;
  height: 32px;
  background: rgba(245, 158, 11, 0.12);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f59e0b;
  flex-shrink: 0;
}

.storage-account-item.active .storage-account-icon {
  background: rgba(245, 158, 11, 0.2);
}

.storage-account-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.storage-account-item.active .storage-account-name {
  color: var(--sidebar-text-bright);
}

.storage-account-meta {
  font-size: 0.68rem;
  color: var(--sidebar-text-muted);
  margin-top: 2px;
}

.storage-account-info {
  flex: 1;
  min-width: 0;
}

/* ═══════════════════════════════════════════
   SYNC UPLOAD — Per-Channel Compare & Upload
   ═══════════════════════════════════════════ */
.storage-sync-btn {
  background: none;
  border: none;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
  opacity: 0;
}

.storage-account-item:hover .storage-sync-btn {
  opacity: 1;
}

.storage-sync-btn:hover {
  color: #10b981;
  background: rgba(16, 185, 129, 0.15);
}

.sync-upload-container {
  padding: var(--space-base);
}

.sync-legend {
  display: flex;
  gap: 18px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.sync-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sync-dot.uploaded {
  background: #10b981;
}

.sync-dot.local-only {
  background: #f59e0b;
}

.sync-dot.remote-only {
  background: #6366f1;
}

.sync-file-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.sync-file-summary strong {
  color: var(--text);
}

.sync-file-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 55vh;
  overflow-y: auto;
}

.sync-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  transition: all var(--transition);
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
}

.sync-file-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Uploaded (exists both locally and remotely) */
.sync-file-item.uploaded {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.15);
}

.sync-file-item.uploaded .sync-file-name {
  color: #6ee7b7;
}

.sync-file-item.uploaded .sync-file-status {
  color: #10b981;
}

/* Local only (not uploaded yet) */
.sync-file-item.local-only {
  background: rgba(245, 158, 11, 0.06);
  border-color: rgba(245, 158, 11, 0.2);
}

.sync-file-item.local-only .sync-file-name {
  color: #fbbf24;
}

.sync-file-item.local-only .sync-file-status {
  color: #f59e0b;
}

/* Remote only (not local) */
.sync-file-item.remote-only {
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.15);
}

.sync-file-item.remote-only .sync-file-name {
  color: #a5b4fc;
}

.sync-file-item.remote-only .sync-file-status {
  color: #6366f1;
}

/* Selected state overlay */
.sync-file-item.selected {
  border-color: #10b981 !important;
  background: rgba(16, 185, 129, 0.12) !important;
}

.sync-file-item .sync-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.sync-file-item.selected .sync-checkbox {
  background: #10b981;
  border-color: #10b981;
}

.sync-file-item .sync-file-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sync-file-item.uploaded .sync-file-icon {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.sync-file-item.local-only .sync-file-icon {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.sync-file-item.remote-only .sync-file-icon {
  background: rgba(99, 102, 241, 0.15);
  color: #6366f1;
}

.sync-file-item .sync-file-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.sync-file-item .sync-file-size {
  color: var(--text-muted);
  font-size: 0.72rem;
  flex-shrink: 0;
  min-width: 55px;
  text-align: right;
}

.sync-file-item .sync-file-status {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  min-width: 80px;
  text-align: right;
}

.sync-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ═══════════════════════════════════════════
   MANAGE POST — Bulk Upload
   ═══════════════════════════════════════════ */
.manage-post-container {
  padding: var(--space-base);
}

.manage-post-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--space-lg);
}

.manage-post-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.manage-post-dropzone {
  border: 2px dashed rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: rgba(139, 92, 246, 0.04);
}

.manage-post-dropzone:hover,
.manage-post-dropzone.dragover {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.1);
}

.manage-post-dropzone p {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.manage-post-dropzone strong {
  color: #a78bfa;
  cursor: pointer;
}

.manage-post-file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.manage-post-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.82rem;
}

.manage-post-file-item .file-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.manage-post-file-item .file-icon.image {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.manage-post-file-item .file-icon.video {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.manage-post-file-item .file-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-weight: 500;
}

.manage-post-file-item .file-size {
  color: var(--text-muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.manage-post-file-item .file-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  transition: all var(--transition);
}

.manage-post-file-item .file-remove:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.manage-post-name-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.manage-post-channel-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}

.manage-post-channel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  border: 1.5px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  user-select: none;
}

.manage-post-channel-item:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.1);
}

.manage-post-channel-item.selected {
  background: rgba(139, 92, 246, 0.1);
  border-color: #8b5cf6;
}

.manage-post-channel-item .channel-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.manage-post-channel-item.selected .channel-checkbox {
  background: #8b5cf6;
  border-color: #8b5cf6;
}

.manage-post-channel-item .channel-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.manage-post-channel-item.selected .channel-name {
  color: #a78bfa;
}

.manage-post-progress-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.manage-post-progress-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.82rem;
}

.manage-post-progress-item .progress-icon {
  flex-shrink: 0;
}

.manage-post-progress-item .progress-channel {
  font-weight: 600;
  color: var(--text);
  min-width: 120px;
}

.manage-post-progress-item .progress-status {
  flex: 1;
  color: var(--text-muted);
}

.manage-post-progress-item.success {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.05);
}

.manage-post-progress-item.error {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
}

.manage-post-progress-item.uploading {
  border-color: rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.05);
}

/* ═══════════════════════════════════════════
   STORAGE CRM — Detail View
   ═══════════════════════════════════════════ */
.storage-detail {
  min-height: 400px;
}

.storage-detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 40px;
  text-align: center;
  gap: 12px;
}

.storage-detail-empty h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.storage-detail-empty p {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 320px;
}

.storage-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border-light);
}

.storage-detail-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.storage-back-btn {
  flex-shrink: 0;
}

.storage-file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.storage-file-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  transition: all var(--transition);
  cursor: default;
}

.storage-file-item:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

.storage-file-item.is-folder {
  cursor: pointer;
}

.storage-file-item.is-folder:hover {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.03);
}

.storage-file-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.storage-file-icon.folder {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.storage-file-icon.file {
  background: var(--primary-light);
  color: var(--primary);
}

.storage-file-icon.image {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.storage-file-icon.video {
  background: rgba(139, 92, 246, 0.1);
  color: var(--warning);
}

.storage-file-info {
  flex: 1;
  min-width: 0;
}

.storage-file-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.storage-file-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.storage-file-size {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.storage-file-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.storage-file-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

.storage-file-item:hover .storage-file-actions {
  opacity: 1;
}

.storage-action-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.storage-action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.storage-action-btn.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-light);
}

.storage-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.storage-loading .spinner {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: #f59e0b;
}

.storage-sidebar .storage-loading .spinner {
  border-color: rgba(255, 255, 255, 0.15);
  border-top-color: #f59e0b;
}

/* ═══════════════════════════════════════════
   PRODUCTION MODE
   ═══════════════════════════════════════════ */
/* ─── Production Two-Column Layout ─── */
.prod-tree-section {
  display: flex;
  gap: 16px;
  min-height: 280px;
}

.prod-panel {
  flex: 1;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
}

.prod-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-shrink: 0;
}

.prod-panel-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
}

.prod-panel-header-left svg {
  color: var(--warning);
}

.prod-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

/* New group form */
.new-group-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(139, 92, 246, 0.06);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.new-group-input {
  flex: 1;
  padding: 6px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: var(--text);
  font-family: inherit;
  background: var(--bg-card);
}

.new-group-input:focus {
  outline: none;
  border-color: var(--warning);
}

/* ─── Group List (Left Panel) ─── */
.group-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  border-bottom: 1px solid var(--border-light);
}

.group-list-item:last-child {
  border-bottom: none;
}

.group-list-item:hover {
  background: var(--bg);
}

.group-list-item.active {
  background: rgba(139, 92, 246, 0.08);
  border-left: 3px solid var(--warning);
}

.group-list-icon {
  color: var(--warning);
  flex-shrink: 0;
}

.group-list-info {
  flex: 1;
  min-width: 0;
}

.group-list-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-list-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.group-list-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}

.group-list-item:hover .group-list-actions {
  opacity: 1;
}

.group-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: all var(--transition);
}

.group-action-btn:hover {
  color: var(--danger);
  background: var(--danger-light);
}

/* ─── Preset List (Right Panel) ─── */
.prod-preset-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  border-radius: 0;
  border-bottom: 1px solid var(--border-light);
}

.prod-preset-item:last-child {
  border-bottom: none;
}

.prod-preset-item:hover {
  background: var(--bg);
}

.prod-preset-item.checked {
  background: rgba(139, 92, 246, 0.05);
}

.prod-preset-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 5px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  background: var(--bg-card);
}

.prod-preset-item.checked .prod-preset-checkbox {
  background: #8b5cf6;
  border-color: #8b5cf6;
}

.prod-preset-checkbox svg {
  display: none;
}

.prod-preset-item.checked .prod-preset-checkbox svg {
  display: block;
}

.prod-preset-info {
  flex: 1;
  min-width: 0;
}

.prod-preset-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prod-preset-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Empty state */
.prod-empty-state {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

/* Settings */
.prod-settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.prod-settings-row:last-child {
  margin-bottom: 0;
}

.prod-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 140px;
}

.prod-text-input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text);
  font-family: inherit;
  background: var(--bg);
}

.prod-text-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Results */
.prod-results {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 2px solid var(--border-light);
}

.prod-results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prod-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
}

.prod-result-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.prod-result-icon.success {
  background: var(--success-light);
  color: var(--success);
}

.prod-result-icon.error {
  background: var(--danger-light);
  color: var(--danger);
}

.prod-result-info {
  flex: 1;
  min-width: 0;
}

.prod-result-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.prod-result-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Spinner ─── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ═══════════════════════════════════════════
   INSTA CRM
   ═══════════════════════════════════════════ */

.insta-account-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-base) var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-base);
}

.insta-account-title h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.insta-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-base) var(--space-lg);
  margin-bottom: var(--space-base);
}

.insta-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-md);
}

.insta-section-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.insta-step-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e1306c, #fd1d1d);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* File grid */
.insta-file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding: 2px;
}

.insta-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--bg);
  user-select: none;
}

.insta-file-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.insta-file-card.selected {
  border-color: #e1306c;
  background: rgba(225, 48, 108, 0.06);
  box-shadow: 0 0 0 1px rgba(225, 48, 108, 0.15);
}

.insta-file-check {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.insta-file-card.selected .insta-file-check {
  background: #e1306c;
  border-color: #e1306c;
}

.insta-file-check svg {
  opacity: 0;
}

.insta-file-card.selected .insta-file-check svg {
  opacity: 1;
}

.insta-file-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insta-file-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.insta-file-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.insta-file-badge.unposted {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.insta-file-badge.posted {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

.insta-file-card.is-posted {
  opacity: 0.5;
}

.insta-file-card.is-posted:hover {
  opacity: 0.75;
}

/* Caption mode toggle */
.insta-caption-mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: var(--space-md);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border);
  width: fit-content;
}

.insta-caption-mode-btn {
  padding: 6px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.insta-caption-mode-btn.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.insta-caption-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: border-color var(--transition);
}

.insta-caption-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.insta-caption-separate-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.insta-caption-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.insta-caption-item-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.insta-caption-item textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-family: inherit;
  resize: vertical;
  background: var(--bg-card);
  color: var(--text);
  line-height: 1.4;
  min-height: 60px;
}

.insta-caption-item textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* Schedule */
.insta-schedule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.insta-schedule-field label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.insta-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition);
}

.insta-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Schedule preview */
.insta-schedule-preview {
  margin-top: var(--space-md);
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 260px;
  overflow-y: auto;
}

.insta-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border-light);
}

.insta-preview-row:last-child {
  border-bottom: none;
}

.insta-preview-idx {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.insta-preview-file {
  flex: 1;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insta-preview-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

/* Schedule mode pills */
.insta-schedule-modes {
  display: flex;
  gap: 0;
  margin-bottom: var(--space-md);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border);
  width: fit-content;
}

.insta-schedule-mode-btn {
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.insta-schedule-mode-btn.active {
  background: linear-gradient(135deg, #e1306c, #fd1d1d);
  color: #fff;
  box-shadow: 0 2px 6px rgba(225, 48, 108, 0.3);
}

.insta-schedule-mode-btn:not(.active):hover {
  background: var(--bg-card);
  color: var(--text);
}

.insta-quick-summary {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 8px 0;
  line-height: 1.5;
}

.insta-quick-summary strong {
  color: var(--text);
}

/* Queue panel */
.insta-queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.insta-queue-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.insta-queue-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #e1306c, #fd1d1d);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.insta-queue-card-info {
  flex: 1;
  min-width: 0;
}

.insta-queue-card-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.insta-queue-card-detail {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.insta-queue-card-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.insta-queue-card-remove:hover {
  color: var(--danger);
  background: var(--danger-light);
}

.insta-queue-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #8b5cf6;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 1100px) {
  .app {
    flex-direction: column;
    height: auto;
  }

  body {
    overflow: auto;
  }

  .sidebar {
    width: 100%;
    min-width: unset;
    max-height: none;
  }

  .sidebar::before {
    display: none;
  }

  .sidebar-scroll {
    max-height: 50vh;
  }

  .main-content {
    padding: var(--space-lg);
  }

  .main-content::before {
    left: 0;
  }

  .prod-tree-section {
    flex-direction: column;
  }

  .action-bar {
    flex-direction: column;
  }

  .format-row {
    gap: 10px;
  }

  .result-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .video-player-wrap {
    max-width: 100%;
  }
}

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

  .color-row {
    flex-direction: column;
  }

  .main-content {
    padding: var(--space-base);
  }

  .template-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ═══════════════════════════════════════════
   Storage CRM — Merged channel view
   ═══════════════════════════════════════════ */
.merged-toolbar {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  margin-bottom: 8px;
  z-index: 5;
}
.merged-toolbar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.merged-toolbar-spacer { flex: 1; }

.merged-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition);
}
.merged-filter-pill:hover {
  color: var(--text-primary);
  border-color: var(--border);
}
.merged-filter-pill.active {
  color: #6366f1;
  background: rgba(99,102,241,0.08);
  border-color: rgba(99,102,241,0.3);
}
.merged-filter-count {
  display: inline-block;
  min-width: 18px;
  text-align: center;
  padding: 1px 6px;
  font-size: 0.68rem;
  border-radius: 999px;
  background: var(--bg-soft, rgba(0,0,0,0.05));
}
.merged-filter-pill.active .merged-filter-count {
  background: rgba(99,102,241,0.18);
  color: #4f46e5;
}

.merged-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}
.merged-checkbox:hover { border-color: #6366f1; }
.merged-checkbox.checked {
  background: #10b981;
  border-color: #10b981;
}

.merged-status-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 999px;
  text-transform: uppercase;
  white-space: nowrap;
}
.merged-status-badge.uploaded { color: #047857; background: rgba(16,185,129,0.12); }
.merged-status-badge.local-only { color: #b45309; background: rgba(245,158,11,0.14); }
.merged-status-badge.remote-only { color: #6b7280; background: rgba(107,114,128,0.12); }

/* ═══════════════════════════════════════════
   Insta CRM — Schedule / Posts view toggle (replaces .insta-account-header)
   ═══════════════════════════════════════════ */
.insta-view-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--space-base);
  padding: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}
.insta-view-toggle-tabs {
  display: inline-flex;
  gap: 4px;
  background: rgba(0,0,0,0.04);
  padding: 4px;
  border-radius: 999px;
}
.insta-view-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition);
}
.insta-view-tab:hover { color: var(--text-primary); }
.insta-view-tab.active {
  color: #fff;
  background: linear-gradient(135deg, #e1306c, #fd1d1d);
  box-shadow: 0 2px 8px rgba(225, 48, 108, 0.35);
}
.insta-view-account-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-left: auto;
  padding-right: 8px;
}
.insta-view-account-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Posts list */
.insta-posts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.insta-post-card {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  align-items: center;
}
.insta-post-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: rgba(0,0,0,0.05);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #9ca3af);
}
.insta-post-thumb video,
.insta-post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.insta-post-info { min-width: 0; }
.insta-post-caption {
  font-size: 0.82rem;
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.insta-post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.insta-post-status {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 999px;
  text-transform: uppercase;
}
.insta-post-status.pending { color: #b45309; background: rgba(245,158,11,0.14); }
.insta-post-status.posted { color: #047857; background: rgba(16,185,129,0.12); }
.insta-post-status.published { color: #047857; background: rgba(16,185,129,0.12); }
.insta-post-status.failed { color: #b91c1c; background: rgba(239,68,68,0.12); }
.insta-post-status.processing { color: #4f46e5; background: rgba(99,102,241,0.14); }
.insta-post-status.cancelled { color: #6b7280; background: rgba(107,114,128,0.14); }

.insta-post-link {
  color: #4f46e5;
  font-weight: 600;
  text-decoration: none;
}
.insta-post-link:hover { text-decoration: underline; }

.insta-posts-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

/* Sidebar "Connect Facebook" button (Storage CRM + Insta CRM) */
.connect-fb-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  margin: 8px 0 4px;
  background: rgba(24, 119, 242, 0.08);
  border: 1px solid rgba(24, 119, 242, 0.25);
  color: #1877F2;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.connect-fb-btn:hover {
  background: rgba(24, 119, 242, 0.14);
  border-color: rgba(24, 119, 242, 0.45);
}
.connect-fb-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.merged-file-item.status-local-only { border-left: 3px solid #f59e0b; }
.merged-file-item.status-uploaded { border-left: 3px solid #10b981; }
.merged-file-item.status-remote-only { border-left: 3px solid #9ca3af; }

/* ═══════════════════════════════════════════
   Insta CRM — Multi Schedule
   ═══════════════════════════════════════════ */
.insta-multi-times-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.insta-multi-time-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto 28px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}
.insta-multi-time-idx {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  background: rgba(99,102,241,0.12);
  color: #4f46e5;
}
.insta-multi-time-file {
  font-size: 0.78rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.insta-multi-time-input {
  width: 110px;
  padding: 4px 8px;
  font-size: 0.78rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg);
}
.insta-multi-time-jitter {
  font-size: 0.7rem;
  color: var(--text-muted, #9ca3af);
  font-variant-numeric: tabular-nums;
}
.insta-multi-time-remove {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-light);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: #ef4444;
}
.insta-multi-time-remove:hover { background: rgba(239,68,68,0.08); }
