/* =========================================================
   Estúdio Editorial & Reels — Instituto Estrela do Bem
   Design System Minimalista de Alto Contraste (3-Pane Studio)
   ========================================================= */

:root {
  --bg: #F5F7FA;
  --stage-bg: #EEF1F6;
  --stage-dot: #D1D9E6;
  --surface: #FFFFFF;
  --surface-subtle: #FAFAFC;
  --surface-muted: #F1F4F9;
  --surface-hover: #EBF0F6;

  --ink: #181922;
  --ink-secondary: #3E4554;
  --ink-muted: #647084;
  --ink-faint: #8C97AA;

  --border: #E2E7F0;
  --border-strong: #CBD4E1;

  --brand-navy: #0B3A75;
  --brand-navy-hover: #0E4994;
  --brand-emerald: #15803D;
  --brand-emerald-hover: #166534;
  --brand-emerald-soft: #ECFDF5;
  --brand-amber-soft: #FFFBEB;
  --brand-amber-ink: #92400E;
  --danger: #DC2626;
  --danger-hover: #B91C1C;
  --danger-soft: #FEF2F2;
  --danger-border: #FECACA;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 11px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-xs: 0 1px 2px rgba(24, 25, 34, 0.04);
  --shadow-sm: 0 2px 8px rgba(24, 25, 34, 0.06);
  --shadow-md: 0 12px 32px rgba(24, 25, 34, 0.09);
  --shadow-canvas: 0 28px 64px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.08);

  --topbar-h: 58px;
  --left-w: 288px;
  --right-w: 364px;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 13px;
  line-height: 1.45;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

/* Custom subtle scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D3DBE7; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #B6C2D4; }

.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 SHELL
   ========================================================= */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* TOPBAR */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand img {
  height: 34px;
  width: auto;
  display: block;
  object-fit: contain;
}
.brand-text { min-width: 0; }
.brand-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.015em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  font-size: 11px;
  color: var(--ink-muted);
  font-weight: 500;
  white-space: nowrap;
}

.save-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--ink-muted);
  font-size: 11.2px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.save-pill:hover { border-color: var(--border-strong); color: var(--ink); background: var(--surface-muted); }
.save-pill .status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #16A34A;
  flex-shrink: 0;
}
.save-pill.is-cloud {
  border-color: #BBF7D0;
  background: var(--brand-emerald-soft);
  color: #166534;
}
.save-pill.is-saving .status-dot {
  background: #D97706;
  animation: pulseDot 1s infinite ease-in-out;
}
.save-pill.is-error {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}
.save-pill.is-error .status-dot { background: var(--danger); }

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.divider-v {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 2px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.4px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-muted); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #FFFFFF;
}
.btn-primary:hover:not(:disabled) { background: #2A2C3B; border-color: #2A2C3B; }

.btn-navy {
  background: var(--brand-navy);
  border-color: var(--brand-navy);
  color: #FFFFFF;
}
.btn-navy:hover:not(:disabled) { background: var(--brand-navy-hover); border-color: var(--brand-navy-hover); }

.btn-reels {
  background: var(--brand-emerald);
  border-color: var(--brand-emerald);
  color: #FFFFFF;
}
.btn-reels:hover:not(:disabled) { background: var(--brand-emerald-hover); border-color: var(--brand-emerald-hover); }

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-secondary);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-muted); color: var(--ink); border-color: transparent; }

.btn-danger-soft {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-soft);
}
.btn-danger-soft:hover:not(:disabled) { background: #FEE2E2; border-color: #FCA5A5; }

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

.btn-sm { height: 29px; padding: 0 10px; font-size: 11.8px; border-radius: 7px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 11px; border-radius: 6px; }
.btn-icon { width: 32px; height: 32px; padding: 0; }
.btn-icon-sm { width: 26px; height: 26px; padding: 0; border-radius: 6px; }

/* =========================================================
   3-PANE STUDIO WORKSPACE
   ========================================================= */
.workspace {
  display: grid;
  grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* LEFT RAIL: BIBLIOTECA */
.left-rail {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.rail-head {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  flex-shrink: 0;
}

.rail-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rail-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.rail-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  background: var(--surface-muted);
  padding: 2px 7px;
  border-radius: 999px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-box svg {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--ink-faint);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  height: 33px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px 0 32px;
  font-size: 12.2px;
  background: var(--surface-subtle);
  outline: none;
  transition: all 0.14s ease;
}
.search-box input:focus {
  border-color: var(--brand-navy);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(11, 58, 117, 0.08);
}

.pillar-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.pillar-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}
.pillar-pill:hover { border-color: var(--border-strong); color: var(--ink); }
.pillar-pill.active { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.rail-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rail-filter-row select {
  flex: 1;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 8px;
  font-size: 11.4px;
  font-weight: 600;
  color: var(--ink-secondary);
  background: var(--surface-subtle);
  outline: none;
  cursor: pointer;
}

.library-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pillar-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pillar-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}
.pillar-section-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.post-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  transition: all 0.14s ease;
}
.post-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-subtle);
}
.post-item.active {
  border-color: var(--ink);
  background: #F8FAFD;
  box-shadow: 0 0 0 1px var(--ink), var(--shadow-xs);
}

.post-thumb {
  width: 38px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: #1C222D;
  border: 1px solid rgba(15, 23, 42, 0.08);
  flex-shrink: 0;
}
.post-item-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.post-item-title {
  font-size: 12.4px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.post-item-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1.5px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
}
.badge-rascunho { background: #F1F5F9; color: #475569; }
.badge-revisao { background: #FEF3C7; color: #92400E; }
.badge-pronto { background: #DCFCE7; color: #166534; }
.badge-publicado { background: #DBEAFE; color: #1E40AF; }
.badge-fmt { background: #F3E8FF; color: #6B21A8; }
.badge-no-photo { background: #FEF2F2; color: #B91C1C; }

.post-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s ease;
  flex-shrink: 0;
}
.post-item:hover .post-item-actions,
.post-item.active .post-item-actions,
.post-item:focus-within .post-item-actions {
  opacity: 1;
}

.mini-action {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s ease;
}
.mini-action:hover {
  background: var(--surface-hover);
  color: var(--ink);
  border-color: var(--border);
}
.mini-action.is-delete:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}
.mini-action svg { width: 13px; height: 13px; }

.rail-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

/* =========================================================
   CENTER STAGE: PALCO LIMPO
   ========================================================= */
.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background-color: var(--stage-bg);
  background-image: radial-gradient(var(--stage-dot) 1px, transparent 1px);
  background-size: 20px 20px;
  position: relative;
  overflow: hidden;
}

.stage-toolbar {
  padding: 12px 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  z-index: 5;
}

.stage-pill-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 4px 6px;
  box-shadow: var(--shadow-xs);
  max-width: 100%;
}

.stage-post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
  min-width: 0;
}
.stage-post-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 12.8px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.stage-dims {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.seg-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 2px;
  background: var(--surface-muted);
  border-radius: 8px;
}
.seg-btn {
  height: 28px;
  padding: 0 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-muted);
  font-size: 11.6px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

.toggle-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
}
.toggle-icon-btn:hover { background: var(--surface-muted); color: var(--ink); }
.toggle-icon-btn.active {
  background: #EFF6FF;
  border-color: #BFDBFE;
  color: var(--brand-navy);
}
.toggle-icon-btn svg { width: 14px; height: 14px; }

.stage-viewport {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 24px;
  overflow: auto;
  position: relative;
}

.canvas-frame {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-canvas);
  background: #1C222D;
  flex-shrink: 0;
  transition: width 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.canvas-frame.fmt-4-5 {
  width: min(500px, calc((100vh - 204px) * 0.8));
  aspect-ratio: 4 / 5;
}
.canvas-frame.fmt-9-16 {
  width: min(370px, calc((100vh - 204px) * 0.5625));
  aspect-ratio: 9 / 16;
}
.canvas-frame.drag-active {
  outline: 3px dashed var(--brand-navy);
  outline-offset: 8px;
}
#artCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Empty Stage State (when all posts are deleted) */
.empty-stage {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  max-width: 360px;
  padding: 32px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}
.empty-stage.show { display: flex; }
.empty-stage-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--ink-muted);
  display: flex; align-items: center; justify-content: center;
}
.empty-stage-icon svg { width: 22px; height: 22px; }
.empty-stage h3 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 16px;
  font-weight: 800;
}
.empty-stage p { font-size: 12.6px; color: var(--ink-muted); line-height: 1.5; }

/* Bottom Floating Playback Dock */
.stage-dock-wrap {
  padding: 0 18px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stage-dock {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 12px;
  box-shadow: var(--shadow-sm);
  width: min(560px, 100%);
}
.dock-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.dock-counter {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-muted);
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.timeline-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.timeline-fill {
  height: 100%;
  width: 100%;
  background: var(--ink);
  border-radius: 999px;
}
.time-readout {
  font-size: 11.2px;
  font-weight: 600;
  color: var(--ink-muted);
  min-width: 68px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   RIGHT RAIL: INSPECTOR CONTEXTUAL
   ========================================================= */
.right-rail {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.inspector-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 8px 10px;
  gap: 5px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  flex-shrink: 0;
}
.inspector-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-size: 12.2px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}
.inspector-tab svg { width: 14px; height: 14px; }
.inspector-tab:hover { color: var(--ink); background: var(--surface-muted); }
.inspector-tab.active {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

.inspector-panel {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
}
.inspector-panel.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.group-card {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.group-title {
  font-size: 10.8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.field label {
  font-size: 11.8px;
  font-weight: 600;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.field-hint {
  font-size: 11px;
  color: var(--ink-muted);
  font-weight: 400;
}
.field input[type="text"],
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12.6px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: all 0.14s ease;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--brand-navy);
  box-shadow: 0 0 0 3px rgba(11, 58, 117, 0.08);
}
.field textarea { resize: vertical; line-height: 1.48; }

.range-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.range-row input[type="range"] { width: 100%; accent-color: var(--ink); cursor: pointer; }
.range-val {
  font-size: 11.2px;
  font-weight: 600;
  color: var(--ink-muted);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Visual 2x2 Quadrant Selector */
.quad-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quad-col { display: flex; flex-direction: column; gap: 5px; }
.quad-col-label { font-size: 11.4px; font-weight: 600; color: var(--ink-secondary); }
.quad-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.quad-btn {
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--ink-muted);
  font-size: 10.6px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}
.quad-btn:hover { border-color: var(--border-strong); color: var(--ink); }
.quad-btn.active { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }

.inline-alert {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--brand-amber-soft);
  border: 1px solid #FDE68A;
  color: var(--brand-amber-ink);
  font-size: 11.4px;
  font-weight: 500;
}
.inline-alert.show { display: flex; }

/* Art Styles & Swatches */
.style-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.style-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 6px;
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: all 0.14s ease;
}
.style-card:hover { border-color: var(--border-strong); }
.style-card.active { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.style-card strong { display: block; font-size: 11.6px; margin-bottom: 1px; }
.style-card small { display: block; font-size: 10px; opacity: 0.76; }

.swatches { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}
.swatch:hover { transform: scale(1.1); }
.swatch.active {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px #FFF, 0 0 0 4px var(--ink);
}

/* Switch toggle */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.2px;
  font-weight: 500;
  color: var(--ink-secondary);
}
.switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: #CBD5E1; border-radius: 999px;
  cursor: pointer; transition: 0.18s;
}
.slider::before {
  content: ""; position: absolute;
  width: 14px; height: 14px; left: 3px; top: 3px;
  background: #FFF; border-radius: 50%;
  transition: 0.18s; box-shadow: 0 1px 2px rgba(0,0,0,0.18);
}
.switch input:checked + .slider { background: var(--ink); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* Upload dropzone */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: 9px;
  padding: 10px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.14s ease;
  font-size: 11.4px;
  color: var(--ink-muted);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand-navy);
  background: #F0F7FF;
  color: var(--brand-navy);
}
.dropzone strong { color: var(--ink); display: block; margin-bottom: 2px; font-size: 12px; }

/* Reels Presets */
.preset-list { display: flex; flex-direction: column; gap: 6px; }
.preset-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: all 0.14s ease;
}
.preset-card:hover { border-color: var(--border-strong); }
.preset-card.active { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.preset-card strong { display: block; font-size: 12.2px; margin-bottom: 2px; }
.preset-card small { display: block; font-size: 10.8px; opacity: 0.78; line-height: 1.35; }

.rec-box {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-radius: 9px;
  background: var(--brand-emerald-soft);
  border: 1px solid #BBF7D0;
  color: #166534;
  font-size: 11.8px;
  font-weight: 600;
}
.rec-box.show { display: flex; }
.rec-track { height: 6px; border-radius: 999px; background: #DCFCE7; overflow: hidden; }
.rec-fill { height: 100%; width: 0%; background: #16A34A; transition: width 0.08s linear; }

.danger-zone-row {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

.hr-line { border: none; border-top: 1px solid var(--border); margin: 2px 0; }

/* =========================================================
   MODALS & TOAST WITH UNDO
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 16px;
  width: min(760px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.24);
  border: 1px solid var(--border);
}
.modal-sm { width: min(430px, 100%); }
.modal-md { width: min(500px, 100%); }
.modal-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.modal-head h3 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  font-weight: 800;
}
.modal-body {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* Instagram 3x3 Preview */
.ig-phone {
  width: min(420px, 100%);
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  background: #FFF;
}
.ig-head {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.ig-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); padding: 4px;
  object-fit: contain; background: #FFF;
}
.ig-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; background: #E2E8F0; }
.ig-cell {
  aspect-ratio: 3 / 4; background: #181922;
  overflow: hidden; position: relative; cursor: pointer;
}
.ig-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ig-cell-tag {
  position: absolute; bottom: 4px; left: 4px;
  background: rgba(15,23,42,0.78); color: #FFF;
  font-size: 9.5px; font-weight: 600; padding: 2px 5px;
  border-radius: 4px; max-width: calc(100% - 8px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Cloud Sync Info List */
.sync-steps {
  display: flex; flex-direction: column; gap: 8px;
  font-size: 12.5px; color: var(--ink-secondary); line-height: 1.5;
  padding-left: 18px;
}
.code-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--ink);
}

/* Toast with optional Undo button */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translate(-50%, 16px);
  background: var(--ink);
  color: #FFFFFF;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 12.6px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 200;
}
.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}
.toast-undo {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  font-size: 11.8px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
}
.toast-undo:hover { background: rgba(255, 255, 255, 0.24); }

/* Mobile drawer toggle buttons (hidden on desktop) */
.mobile-toggle { display: none; }

/* =========================================================
   RESPONSIVE BREAKPOINTS
   ========================================================= */
@media (max-width: 1180px) {
  :root { --left-w: 256px; --right-w: 332px; }
  .brand-sub { display: none; }
}

@media (max-width: 960px) {
  .app { height: auto; min-height: 100vh; overflow: visible; }
  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }
  .left-rail {
    order: 2;
    border-right: none;
    border-top: 1px solid var(--border);
    max-height: 420px;
  }
  .stage {
    order: 1;
    min-height: 580px;
  }
  .right-rail {
    order: 3;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .canvas-frame.fmt-4-5 { width: min(410px, 90vw); }
  .canvas-frame.fmt-9-16 { width: min(300px, 82vw); }
  .topbar { height: auto; padding: 10px 14px; flex-wrap: wrap; }
  .divider-v { display: none; }
}


/* =========================================================
   V2 EXTENSIONS — JOYFUL PRESETS & INFORMATIVE BLOCKS
   ========================================================= */
.style-cards-4 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}
.style-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 9px 10px;
  gap: 2px;
}
.style-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 6px;
}
.style-dots {
  display: inline-flex;
  gap: 3px;
}
.style-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.highlight-editor-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.highlight-editor-row {
  display: grid;
  grid-template-columns: 98px 1fr;
  gap: 6px;
  align-items: center;
}
.highlight-editor-row select {
  padding: 7px 6px !important;
  font-size: 11.5px !important;
  font-weight: 600;
}
.highlight-editor-row input {
  padding: 7px 9px !important;
  font-size: 12px !important;
}

.quick-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.quick-badge-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-secondary);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10.6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}
.quick-badge-btn:hover {
  border-color: var(--brand-navy);
  color: var(--brand-navy);
  background: #EFF6FF;
}


/* =========================================================
   V3 EXTENSIONS — DYNAMIC HIGHLIGHTS & WHATSAPP EXPORT
   ========================================================= */
.btn-whatsapp {
  background: #16A34A;
  border-color: #16A34A;
  color: #FFFFFF;
}
.btn-whatsapp:hover:not(:disabled) {
  background: #15803D;
  border-color: #15803D;
}

.toggle-icon-btn.is-wa.active {
  background: #ECFDF5;
  border-color: #86EFAC;
  color: #166534;
}

.highlight-editor-row-dyn {
  display: grid;
  grid-template-columns: 94px 1fr 28px;
  gap: 6px;
  align-items: center;
}
.highlight-editor-row-dyn select {
  padding: 7px 5px !important;
  font-size: 11.4px !important;
  font-weight: 600;
}
.highlight-editor-row-dyn input {
  padding: 7px 9px !important;
  font-size: 12px !important;
}
.btn-remove-hi {
  width: 28px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s ease;
}
.btn-remove-hi:hover {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}
.btn-remove-hi svg { width: 13px; height: 13px; }

.hi-empty-note {
  font-size: 11.5px;
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 9px 10px;
  text-align: center;
}

.wa-info-banner {
  font-size: 11.3px;
  color: #166534;
  background: #ECFDF5;
  border: 1px solid #BBF7D0;
  border-radius: 8px;
  padding: 7px 9px;
  line-height: 1.42;
}

.batch-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.batch-option-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: var(--surface-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  transition: all 0.14s ease;
}
.batch-option-card:hover {
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.batch-option-card strong {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13.5px;
  color: var(--ink);
}
.batch-option-card span {
  font-size: 11.8px;
  color: var(--ink-muted);
  line-height: 1.45;
}
