/* SeekQuote Editor — Full Tab Layout */

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

:root {
  --accent:      #ff0075;
  --bg:          #111111;
  --surface:     #1e1e1e;
  --surface2:    #252525;
  --border:      rgba(255,255,255,0.09);
  --text:        #ffffff;
  --text-muted:  rgba(255,255,255,0.45);
  --radius:      8px;
  --panel-w:     340px;
  --font:        'Montserrat', sans-serif;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  overflow: hidden;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

#sq-app {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ── Left Panel ──────────────────────────────────────────────────────────── */

#sq-panel {
  width: var(--panel-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  height: 100vh;
  overflow: hidden;
}

#sq-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#sq-logo-text {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--text);
}
#sq-logo-text span { color: var(--accent); }
/* Version badge in the wordmark. Customers may keep 1.x installed beside
   this build, so every surface that names the tool has to distinguish it. */
.sq-version-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  font-style: normal;
  letter-spacing: 0.5px;
  vertical-align: middle;
}


#sq-controls {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#sq-controls::-webkit-scrollbar { width: 4px; }
#sq-controls::-webkit-scrollbar-track { background: transparent; }
#sq-controls::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

#sq-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Right Stage ─────────────────────────────────────────────────────────── */

#sq-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  position: relative;
  overflow: hidden;
  gap: 12px;
}

#sq-stage-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#sq-full-canvas {
  display: block;
  /* sized by JS — box-shadow for depth */
  box-shadow: 0 8px 60px rgba(0,0,0,0.7), 0 2px 12px rgba(0,0,0,0.5);
  border-radius: 2px;
  cursor: grab;
}
#sq-full-canvas:active { cursor: grabbing; }

#sq-size-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

#sq-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  pointer-events: none;
  text-align: center;
  padding: 40px;
}
#sq-placeholder svg { opacity: 0.25; }
#sq-placeholder p { font-size: 13px; line-height: 1.6; opacity: 0.6; }
#sq-placeholder strong { color: var(--accent); font-weight: 700; }
#sq-placeholder.hidden { display: none; }

#sq-loading {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
}
#sq-loading.show { display: flex; }

.sq-spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Shared Controls ─────────────────────────────────────────────────────── */

.sq-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

section { display: flex; flex-direction: column; }

/* Size picker */
.sq-size-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.sq-size-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 7px 2px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.sq-size-btn span  { font-size: 10px; font-weight: 700; color: inherit; }
.sq-size-btn small { font-size: 9px; opacity: 0.55; color: inherit; }
.sq-size-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(255,0,117,0.08); }
.sq-size-btn:hover:not(.active) { border-color: rgba(255,255,255,0.2); color: var(--text); }

.sq-size-icon { background: currentColor; border-radius: 2px; opacity: 0.75; }
.sq-size-square    { width: 20px; height: 20px; }
.sq-size-portrait  { width: 16px; height: 20px; }
.sq-size-landscape { width: 28px; height: 16px; }
.sq-size-story     { width: 13px; height: 24px; }

/* Pills */
.sq-pill-group { display: flex; gap: 6px; }
.sq-pill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 0;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.15s;
}
.sq-pill.active  { background: rgba(255,0,117,0.12); border-color: var(--accent); color: var(--accent); }
.sq-pill:hover:not(.active) { border-color: rgba(255,255,255,0.2); color: var(--text); }

/* Toggles */
.sq-adjust-row { margin-bottom: 8px; }
/* Two toggles sharing a row: half the vertical cost of stacking them */
.sq-toggle-row { display: flex; gap: 6px; }
.sq-toggle-row .sq-toggle { flex: 1; min-width: 0; justify-content: center; }
.sq-toggle:disabled { opacity: 0.35; cursor: not-allowed; }
.sq-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.sq-toggle.active { background: rgba(255,0,117,0.1); border-color: var(--accent); color: var(--accent); }
.sq-toggle:hover:not(.active) { border-color: rgba(255,255,255,0.2); color: var(--text); }

/* Sliders */
.sq-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.sq-slider-label { font-size: 10px; font-weight: 600; color: var(--text-muted); width: 52px; flex-shrink: 0; }
.sq-slider {
  flex: 1;
  height: 3px;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  outline: none;
}
.sq-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.sq-slider-val { font-size: 10px; font-weight: 700; color: var(--text-muted); width: 32px; text-align: right; }

/* Text background options */
.sq-textbg-options {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sq-color-row { display: flex; align-items: center; gap: 8px; }
.sq-color-swatches { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sq-swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, border-color 0.15s;
  position: relative;
}
.sq-swatch:hover { transform: scale(1.15); }
.sq-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.sq-swatch-custom {
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red) !important;
  overflow: hidden;
}
.sq-swatch-custom input[type="color"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
  width: 100%; height: 100%; border: none; padding: 0;
}

/* Buttons */
.sq-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.3px;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  text-transform: uppercase;
}
.sq-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.sq-btn:not(:disabled):active { transform: scale(0.98); }
.sq-btn-primary { background: var(--accent); color: #fff; }
.sq-btn-primary:not(:disabled):hover { opacity: 0.88; }
.sq-btn-secondary { background: var(--surface2); border: 1.5px solid var(--border); color: var(--text-muted); }
.sq-btn-secondary:not(:disabled):hover { border-color: rgba(255,255,255,0.25); color: var(--text); }

.sq-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sq-icon-btn {
  width: 32px; height: 32px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.sq-icon-btn:hover { border-color: rgba(255,255,255,0.25); color: var(--text); }
.sq-icon-btn.accent:hover { border-color: var(--accent); color: var(--accent); }
.sq-icon-btn.active { border-color: var(--accent); color: var(--accent); }

/* Toast */
#sq-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #222;
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  border: 1px solid var(--border);
  white-space: nowrap;
  z-index: 9999;
}
#sq-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#sq-toast.success { border-color: rgba(0,200,100,0.4); color: #4ddd90; }
#sq-toast.error   { border-color: rgba(255,0,117,0.4); color: var(--accent); }

/* ── Caption selection (drag + rotate) ──────────────────────────────────── */

#sq-text-selection {
  position: absolute;
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  pointer-events: none;   /* the canvas underneath handles move-drags */
  z-index: 5;
}

#sq-text-rotate-handle {
  position: absolute;
  top: -34px;
  left: 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: grab;
  pointer-events: auto;
}
#sq-text-rotate-handle:active { cursor: grabbing; }

.sq-text-resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 2px;
  pointer-events: auto;
}
.sq-text-resize-handle[data-corner="tl"] { top: -6px;    left: -6px;  cursor: nwse-resize; }
.sq-text-resize-handle[data-corner="tr"] { top: -6px;    right: -6px; cursor: nesw-resize; }
.sq-text-resize-handle[data-corner="bl"] { bottom: -6px; left: -6px;  cursor: nesw-resize; }
.sq-text-resize-handle[data-corner="br"] { bottom: -6px; right: -6px; cursor: nwse-resize; }

.sq-text-width-handle {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 22px;
  margin-top: -11px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 4px;
  cursor: ew-resize;
  pointer-events: auto;
}
.sq-text-width-handle[data-edge="l"] { left: -5px; }
.sq-text-width-handle[data-edge="r"] { right: -5px; }

/* The logo has no wrap width and no rotation, so it gets corners only. */
#sq-text-selection[data-mode="logo"] #sq-text-rotate-handle,
#sq-text-selection[data-mode="logo"] .sq-text-width-handle { display: none; }
/* A picture rotates and scales, but has no wrap column to reshape. */
#sq-text-selection[data-mode="image"] .sq-text-width-handle { display: none; }

.sq-caption-tip {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 5px;
}

/* Label plus the two pills on one line, matching the slider rows above it.
   The pills take the rest of the row so they line up with the Fill/Fit/Stretch
   group, which is the other thing in this panel shaped like a choice. */
.sq-textcolor-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sq-textcolor-row .sq-pill-group { flex: 1; }

#sq-add-text-btn { width: 100%; padding: 11px; }
#sq-add-picture-btn { width: 100%; padding: 11px; margin-top: 6px; cursor: pointer; }
#sq-add-emoji-btn   { width: 100%; padding: 11px; margin-top: 6px; }
/* Breathing room between the two Add buttons and whatever the selection
   reveals underneath them */
#sq-text-options, #sq-image-options { margin-top: 12px; }
.sq-layer-row { margin-top: 10px; }

.sq-layer-row {
  display: flex;
  gap: 6px;
}
.sq-layer-btn {
  flex: 0 0 auto;
  width: 40px;
  padding: 8px 0;
}
.sq-btn-delete-text {
  flex: 1;
  padding: 8px;
  color: var(--accent);
  border-color: rgba(255,0,117,0.35);
}
.sq-btn-delete-text:not(:disabled):hover { border-color: var(--accent); }

/* In-place text editing: a positioned editor above the block. The canvas
   hides the block while this is visible, so there is exactly one copy. */
#sq-text-editor {
  position: absolute;
  z-index: 6;
  /* content-box on purpose: the global border-box rule pulled the dashed
     border INTO the text column, so the editor wrapped ~3px earlier than the
     canvas did and pushed lines out of the clipped box. */
  box-sizing: content-box;
  background: transparent;
  border: 1.5px dashed var(--accent);
  border-radius: 4px;
  color: #fff;
  font-family: var(--font);
  font-weight: 800;
  line-height: 1.18;
  text-shadow: 0 0 8px rgba(0,0,0,0.9);
  padding: 0;
  margin: 0;
  resize: none;
  overflow: hidden;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}
#sq-text-rotate-handle::after {
  /* stem connecting handle to the box */
  content: '';
  position: absolute;
  top: 14px;
  left: 50%;
  width: 1.5px;
  height: 18px;
  margin-left: -0.75px;
  background: var(--accent);
}

/* ── Slide strip (carousel) ─────────────────────────────────────────────── */

#sq-slide-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 100%;
  padding: 0 24px;
}

#sq-slide-list {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px;
}
#sq-slide-list::-webkit-scrollbar { height: 4px; }
#sq-slide-list::-webkit-scrollbar-track { background: transparent; }
#sq-slide-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sq-slide-item {
  position: relative;
  flex: 0 0 auto;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  overflow: visible;
  transition: border-color 0.15s;
  line-height: 0;
}
.sq-slide-item.active { border-color: var(--accent); }
.sq-slide-item:hover:not(.active) { border-color: rgba(255,255,255,0.3); }

.sq-slide-thumb {
  display: block;
  border-radius: 4px;
  background: #111;
}

.sq-slide-num {
  position: absolute;
  bottom: 3px;
  left: 3px;
  background: rgba(0,0,0,0.7);
  color: var(--text);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 4px;
  pointer-events: none;
}

.sq-slide-del {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: none;
  background: #333;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.sq-slide-item:hover .sq-slide-del { display: flex; }
.sq-slide-del:hover { background: var(--accent); }

#sq-add-slide-btn {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1.5px dashed rgba(255,255,255,0.25);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
#sq-add-slide-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
#sq-add-slide-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Download modal ─────────────────────────────────────────────────────── */

#sq-download-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
#sq-download-modal.show { display: flex; }

.sq-modal-box {
  position: relative;
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 12px 60px rgba(0,0,0,0.6);
}

.sq-modal-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 26px; height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
}
.sq-modal-close:hover { color: var(--text); background: var(--surface2); }

.sq-modal-title {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 16px;
}

.sq-modal-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}
.sq-modal-option:hover { border-color: var(--accent); color: var(--text); }
.sq-modal-option:last-child { margin-bottom: 0; }

.sq-modal-option-text { display: flex; flex-direction: column; gap: 3px; }
.sq-modal-option-text strong { font-size: 13px; font-weight: 700; color: var(--text); }
.sq-modal-option-text small  { font-size: 11px; }

.sq-modal-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.sq-modal-field input {
  width: 80px;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
}
.sq-modal-field input:focus { outline: none; border-color: var(--accent); }

.sq-modal-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.sq-modal-transition {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.sq-modal-transition-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.sq-modal-transition .sq-pill { padding: 8px 12px; font-size: 11px; }

.sq-modal-actions {
  display: flex;
  gap: 10px;
}
.sq-modal-actions .sq-btn { flex: 1; padding: 11px; }

/* ── Emoji modal ────────────────────────────────────────────────────────── */

#sq-emoji-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
#sq-emoji-modal.show { display: flex; }
#sq-emoji-modal .sq-modal-box { width: 360px; }
#sq-emoji-modal .sq-script-help { margin-bottom: 16px; }

.sq-emoji-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.sq-emoji-tile {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  line-height: 1;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s, transform 0.1s;
}
.sq-emoji-tile:hover { border-color: var(--accent); transform: translateY(-2px); }

/* ── Background photo modal ─────────────────────────────────────────────── */

#sq-photo-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
#sq-photo-modal.show { display: flex; }
#sq-photo-modal .sq-modal-box {
  width: 380px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
#sq-photo-modal .sq-script-help { margin-bottom: 10px; }
#sq-photo-modal .sq-modal-hint { margin-bottom: 14px; }

/* Scrolls rather than growing: the library can hold two dozen images and the
   modal still has to fit a short laptop screen. */
.sq-photo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 150px;
  overflow-y: auto;
  margin-bottom: 16px;
  padding-right: 2px;
}

.sq-photo-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--surface2) center/cover no-repeat;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s, transform 0.1s;
}
.sq-photo-tile:hover { border-color: var(--accent); transform: translateY(-2px); }

/* ── Background color modal ─────────────────────────────────────────────── */

#sq-bgcolor-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
#sq-bgcolor-modal.show { display: flex; }
#sq-bgcolor-modal .sq-modal-box { width: 340px; }
#sq-bgcolor-modal .sq-script-help { margin-bottom: 16px; }
#sq-bgcolor-modal .sq-modal-hint { margin-top: 12px; margin-bottom: 0; }

.sq-bg-swatches {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

/* Bigger than the inline text-block swatches on purpose: this is the whole
   canvas, and the modal has the room to show the color properly. */
.sq-bg-swatch {
  flex: 1;
  height: 56px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 0.1s, border-color 0.15s;
}
.sq-bg-swatch:hover { transform: translateY(-2px); }
/* The accent is pink, and one of the saved colors may be too. The dark gap
   between swatch and ring is what makes "selected" readable on any color. */
.sq-bg-swatch.active {
  border-color: var(--surface);
  box-shadow: 0 0 0 2px var(--accent);
}

.sq-bg-swatch-custom {
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  overflow: hidden;
}
.sq-bg-swatch-custom input[type="color"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
  width: 100%; height: 100%; border: none; padding: 0;
}

#sq-bg-clear-btn:disabled { opacity: 0.4; cursor: default; }
#sq-bg-clear-btn:disabled:hover { border-color: var(--border); color: var(--text-muted); }

.sq-placeholder-or { display: inline-block; margin-top: 6px; opacity: 0.75; }

/* A photo-only control, dimmed while a solid color owns the background */
.sq-photo-only-off { opacity: 0.35; pointer-events: none; }

/* ── Script to slides modal ─────────────────────────────────────────────── */

#sq-script-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
#sq-script-modal.show { display: flex; }
#sq-script-modal .sq-modal-box { width: 420px; }

.sq-script-help {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}
.sq-script-help strong { color: var(--accent); }

#sq-script-input {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  padding: 10px 12px;
  resize: vertical;
  min-height: 140px;
  outline: none;
  line-height: 1.5;
  margin-bottom: 10px;
}
#sq-script-input:focus { border-color: rgba(255,0,117,0.5); }
#sq-script-input::placeholder { color: var(--text-muted); }

/* ── Movie export overlay ───────────────────────────────────────────────── */

#sq-export-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10001;
}
#sq-export-overlay.show { display: flex; }

#sq-export-progress {
  font-size: 14px;
  font-weight: 700;
}

.sq-export-note {
  font-size: 11px;
  color: var(--text-muted);
}

/* Drag-and-drop slide reordering */
.sq-slide-item[draggable="true"] { cursor: grab; }
.sq-slide-item[draggable="true"]:active { cursor: grabbing; }
.sq-slide-item.dragging { opacity: 0.42; }
.sq-slide-item.drag-before::before,
.sq-slide-item.drag-after::after {
  content: '';
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  z-index: 5;
}
.sq-slide-item.drag-before::before { left: -7px; }
.sq-slide-item.drag-after::after { right: -7px; }

/* ── Undo + multi-slide background targeting ───────────────────────────── */
#sq-undo-btn:disabled { opacity: 0.32; cursor: default; }
#sq-undo-btn:not(:disabled) { color: var(--text); }

.sq-photo-target-wrap {
  margin: 0 0 14px;
  padding: 11px;
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 10px;
  background: rgba(255,255,255,0.035);
}
.sq-photo-target-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 9px;
}
.sq-photo-target-head strong { font-size: 12px; color: var(--text); }
#sq-photo-select-all {
  border: 0; background: none; color: var(--accent); font: inherit;
  font-size: 11px; font-weight: 700; cursor: pointer; padding: 2px 0;
}
.sq-photo-target-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.sq-photo-target-check {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 32px; padding: 0 9px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.16); color: var(--muted);
  background: rgba(255,255,255,0.035); cursor: pointer; user-select: none;
  font-size: 12px; font-weight: 800; transition: 120ms ease;
}
.sq-photo-target-check input { position: absolute; opacity: 0; pointer-events: none; }
.sq-photo-target-check:has(input:checked) {
  border-color: var(--accent); color: #111; background: var(--accent);
}
.sq-photo-target-hint { margin-top: 8px; color: var(--muted); font-size: 10px; line-height: 1.35; }

/* v2.17 integrated script generator + built-in running backgrounds */
.sq-script-generator-box { width:min(760px, calc(100vw - 40px)); max-height:88vh; overflow:auto; }
.sq-generator-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.sq-modal-field select, .sq-modal-field input, .sq-modal-field textarea {
  width:100%; box-sizing:border-box; background:#171717; color:#f4f4f4; border:1px solid #383838;
  border-radius:8px; padding:10px 11px; font:inherit;
}
.sq-modal-field select:focus, .sq-modal-field input:focus, .sq-modal-field textarea:focus { outline:none; border-color:#0aa03b; }
.sq-field-note { display:block; margin-top:5px; color:#888; font-size:11px; }
.sq-generator-actions { margin-top:8px; }
.sq-script-output-wrap { margin-top:14px; }
#sq-builtin-background-wrap { margin-bottom:16px; }
#sq-builtin-background-grid .sq-photo-tile { min-height:92px; position:relative; }
#sq-builtin-background-grid .sq-photo-tile::after {
  content:attr(data-label); position:absolute; left:6px; right:6px; bottom:6px; padding:4px 6px;
  border-radius:5px; background:rgba(0,0,0,.62); color:white; font-size:10px; font-weight:700; text-align:left;
}
@media (max-width:700px){ .sq-generator-grid{grid-template-columns:1fr;} }

/* v2.18 smart script generator */
.sq-viral-toggle{display:flex;align-items:flex-start;gap:12px;margin:14px 0 18px;padding:14px 16px;border:1px solid #363636;border-radius:14px;background:#171717;cursor:pointer}.sq-viral-toggle input{width:18px;height:18px;margin-top:2px;accent-color:#00a03b;flex:0 0 auto}.sq-viral-toggle span{display:flex;flex-direction:column;gap:4px}.sq-viral-toggle strong{font-size:15px;color:#f3f3f3}.sq-viral-toggle small{font-size:12px;line-height:1.4;color:#8d8d8d}


/* Web v0.1.6: preview zoom + script history */
#sq-preview-zoom{display:flex;align-items:center;gap:6px;color:var(--text-muted);font-size:11px;font-weight:700}
#sq-preview-zoom button{background:var(--surface2);border:1px solid var(--border);color:var(--text);border-radius:6px;min-width:32px;height:30px;font:700 13px var(--font);cursor:pointer}
#sq-preview-zoom #sq-zoom-reset{padding:0 9px}
.sq-script-history-wrap{margin-top:12px;border-top:1px solid var(--border);padding-top:12px}
.sq-script-history-head{display:flex;justify-content:space-between;gap:10px;align-items:center;font-size:11px;color:var(--text-muted);margin-bottom:7px}
#sq-script-history{display:flex;flex-direction:column;gap:6px;max-height:180px;overflow:auto}
.sq-history-item{display:flex;gap:6px;align-items:stretch}
.sq-history-load{flex:1;text-align:left;background:var(--surface2);border:1px solid var(--border);color:var(--text);border-radius:7px;padding:8px 9px;font:600 11px/1.35 var(--font);cursor:pointer}
.sq-history-delete{width:34px;background:var(--surface2);border:1px solid var(--border);color:var(--text-muted);border-radius:7px;cursor:pointer}
@media(max-width:700px){#sq-preview-zoom{position:sticky;bottom:0;z-index:8;background:#0a0a0a;padding:5px 8px;border-radius:8px}.sq-script-history-head{font-size:10px}}


/* v0.1.20 — movie music controls */
.sq-music-settings { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.sq-music-row { display:flex; gap:10px; align-items:center; margin-top:10px; }
.sq-music-row > .sq-btn { flex:0 0 auto; min-width:105px; }
.sq-music-volume { flex:1; display:flex; flex-direction:column; gap:5px; font-size:11px; color:var(--muted); }
.sq-music-volume span { display:flex; justify-content:space-between; gap:10px; }
.sq-music-volume input[type=range] { width:100%; accent-color:var(--accent); }
#sq-music-note { margin-top:8px; }
@media (max-width: 640px) { .sq-music-row { align-items:stretch; flex-direction:column; } .sq-music-row > .sq-btn { width:100%; } }

/* v0.1.21: keep video music controls visible in the main editor */
.sq-music-sidebar { margin-top:0; padding-top:0; border-top:0; }
.sq-music-sidebar .sq-modal-field { margin-bottom:8px; }
.sq-music-sidebar select { width:100%; }
.sq-music-sidebar .sq-music-row { gap:8px; align-items:center; }
.sq-music-sidebar #sq-music-preview { flex:0 0 auto; }
.sq-music-sidebar .sq-music-volume { flex:1; min-width:0; }

