.swmpro-app,
.swmpro-app * { box-sizing: border-box; }

.swmpro-app {
  --swmpro-primary: #e91e73;
  --swmpro-primary-dark: #9d174d;
  --swmpro-ink: #17151f;
  --swmpro-muted: #737083;
  --swmpro-border: #ebe6ef;
  --swmpro-soft: #fff5f9;
  width: 100%;
  max-width: 1240px;
  margin: 28px auto;
  color: var(--swmpro-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

.swmpro-header {
  margin-bottom: 20px;
  padding: 26px 24px;
  border: 1px solid var(--swmpro-border);
  border-radius: 28px;
  text-align: center;
  background:
    radial-gradient(circle at 10% 10%, rgba(233,30,115,.10), transparent 30%),
    radial-gradient(circle at 90% 0%, rgba(126,87,194,.08), transparent 32%),
    linear-gradient(135deg, #fff, #fff9fc);
  box-shadow: 0 18px 45px rgba(30, 20, 40, .055);
}

.swmpro-kicker {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: #fff0f6;
  color: var(--swmpro-primary-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
}

.swmpro-header h2 {
  margin: 12px 0 8px;
  color: var(--swmpro-ink);
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.08;
  letter-spacing: -.035em;
}

.swmpro-header p {
  max-width: 780px;
  margin: 0 auto;
  color: var(--swmpro-muted);
  font-size: 15px;
  line-height: 1.7;
}

.swmpro-admin-note {
  margin-bottom: 18px;
  padding: 13px 16px;
  border: 1px solid #fed7aa;
  border-radius: 18px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 14px;
}
.swmpro-admin-note a { color: #9d174d; font-weight: 800; }

.swmpro-layout {
  display: grid;
  grid-template-columns: minmax(330px, 480px) minmax(420px, 1fr);
  gap: 24px;
  align-items: start;
}

.swmpro-sidebar { display: grid; gap: 16px; min-width: 0; }
.swmpro-preview-panel { min-width: 0; }

.swmpro-card,
.swmpro-preview-sticky {
  border: 1px solid var(--swmpro-border);
  border-radius: 24px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 16px 42px rgba(30, 20, 40, .055);
}
.swmpro-card { padding: 18px; }

.swmpro-card-head,
.swmpro-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.swmpro-card-head h3,
.swmpro-preview-head h3 {
  margin: 0;
  color: var(--swmpro-ink);
  font-size: 16px;
  line-height: 1.25;
}
.swmpro-preview-head p { margin: 5px 0 0; color: #777383; font-size: 13px; line-height: 1.5; }

.swmpro-card-head span {
  white-space: nowrap;
  border-radius: 999px;
  background: #fff0f6;
  color: #be185d;
  font-size: 11px;
  padding: 5px 9px;
  font-weight: 800;
}

.swmpro-app label {
  display: block;
  margin: 11px 0 0;
  color: #3f3f48;
  font-size: 13px;
  font-weight: 800;
}
.swmpro-app label span { color: #9b97a5; font-weight: 700; }

.swmpro-app input[type="text"],
.swmpro-app input[type="search"],
.swmpro-app textarea,
.swmpro-app select {
  width: 100%;
  min-height: 44px;
  margin-top: 7px;
  padding: 11px 13px;
  border: 1px solid #e7e1ec;
  border-radius: 14px;
  outline: none;
  background: #fff;
  color: #1f1d28;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.swmpro-app textarea { resize: vertical; }
.swmpro-app input[type="file"] { width: 100%; margin-top: 8px; font-size: 13px; }
.swmpro-app input:focus,
.swmpro-app textarea:focus,
.swmpro-app select:focus {
  border-color: rgba(233,30,115,.50);
  box-shadow: 0 0 0 4px rgba(233,30,115,.09);
}

.swmpro-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.swmpro-btn {
  appearance: none;
  border: 0;
  min-height: 42px;
  border-radius: 14px;
  padding: 10px 15px;
  cursor: pointer;
  font-weight: 850;
  font-size: 13px;
  line-height: 1;
  letter-spacing: .01em;
  transition: transform .14s ease, opacity .14s ease, box-shadow .14s ease;
}
.swmpro-btn:hover { transform: translateY(-1px); }
.swmpro-primary { width: 100%; margin-top: 15px; background: linear-gradient(135deg, #ec4899, #d61f69); color: #fff; box-shadow: 0 12px 24px rgba(214,31,105,.22); }
.swmpro-soft { background: #fff7fb; color: #a70f4e; border: 1px solid #f2cddd; }
.swmpro-dark { background: #18181b; color: #fff; }

.swmpro-status { margin-top: 10px; color: #71717a; font-size: 13px; }
.swmpro-status.is-error { color: #b91c1c; }
.swmpro-status.is-success { color: #166534; }

.swmpro-results { display: grid; gap: 10px; margin-top: 14px; }
.swmpro-result {
  border: 1px solid #eee7f0;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #fffafd);
  padding: 13px;
}
.swmpro-result p { margin: 0 0 10px; color: #282432; font-size: 14px; line-height: 1.58; }
.swmpro-result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.swmpro-mini-btn {
  appearance: none;
  border: 1px solid #eadfea;
  border-radius: 12px;
  background: #fff;
  color: #3f3f46;
  min-height: 34px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.swmpro-mini-btn:hover { background: #fff7fb; border-color: #f3bfd5; }

.swmpro-symbols { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.swmpro-symbols button {
  appearance: none;
  min-width: 39px;
  min-height: 38px;
  border: 1px solid #eadfea;
  border-radius: 13px;
  background: #fff;
  cursor: pointer;
  font-size: 17px;
  transition: transform .14s ease, background .14s ease, border-color .14s ease;
}
.swmpro-symbols button:hover,
.swmpro-symbols button.is-active { transform: translateY(-1px); background: #fff7fb; border-color: #ec4899; }

.swmpro-template-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 11px; }
.swmpro-template-tabs button {
  appearance: none;
  border: 1px solid #eadfea;
  background: #fff;
  color: #4b4655;
  border-radius: 999px;
  min-height: 34px;
  padding: 7px 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.swmpro-template-tabs button.is-active { background: #18181b; border-color: #18181b; color: #fff; }

.swmpro-template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}
.swmpro-template-card {
  appearance: none;
  width: 100%;
  border: 1px solid #ece5ef;
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.swmpro-template-card:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(30,20,40,.08); }
.swmpro-template-card.is-active { border-color: #ec4899; box-shadow: 0 0 0 3px rgba(236,72,153,.12); }
.swmpro-template-thumb {
  height: 86px;
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 10px;
  overflow: hidden;
}
.swmpro-template-thumb::before,
.swmpro-template-thumb::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(255,255,255,.28);
}
.swmpro-template-thumb::before { width: 70px; height: 70px; right: -20px; top: -20px; }
.swmpro-template-thumb::after { width: 46px; height: 46px; left: 12px; top: 14px; }
.swmpro-template-art {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.36);
  display: grid;
  place-items: center;
  color: rgba(255,255,255,.95);
  font-size: 18px;
  font-weight: 900;
}
.swmpro-template-title {
  position: relative;
  z-index: 1;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0,0,0,.18);
  font-size: 12px;
  font-weight: 900;
}
.swmpro-template-meta { padding: 9px 10px; }
.swmpro-template-name { display: block; color: #1f1d28; font-size: 13px; font-weight: 850; }
.swmpro-template-tag { display: block; margin-top: 3px; color: #898493; font-size: 11px; font-weight: 700; }

.swmpro-color-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.swmpro-color-grid label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #e7e1ec;
  border-radius: 14px;
  background: #fff;
  font-size: 12px;
}
.swmpro-app input[type="color"] { width: 42px; height: 30px; padding: 0; border: 0; background: transparent; cursor: pointer; }

.swmpro-range-list { display: grid; gap: 10px; margin-top: 12px; }
.swmpro-range-list label { display: grid; grid-template-columns: 88px 1fr 38px; gap: 8px; align-items: center; margin: 0; color: #55515f; font-size: 12px; }
.swmpro-app input[type="range"] { width: 100%; accent-color: var(--swmpro-primary); }
.swmpro-range-list output { text-align: right; color: #777383; font-variant-numeric: tabular-nums; }

.swmpro-checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.swmpro-checks label { display: flex; align-items: center; gap: 7px; margin: 0; border: 1px solid #e7e1ec; border-radius: 14px; padding: 9px; background: #fff; font-size: 12px; }
.swmpro-checks input { width: 16px; height: 16px; }

.swmpro-preview-sticky {
  padding: 16px;
  position: sticky;
  top: 76px;
  z-index: 2;
  max-height: calc(100vh - 92px);
  overflow: auto;
}
.admin-bar .swmpro-preview-sticky { top: 96px; max-height: calc(100vh - 112px); }

.swmpro-preview-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.swmpro-preview-actions .swmpro-primary { width: auto; margin-top: 0; }

.swmpro-canvas-wrap {
  border-radius: 24px;
  background: linear-gradient(135deg, #fbf7fb, #f7f8fb);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.swmpro-canvas-wrap canvas {
  display: block;
  max-width: 100%;
  width: auto;
  max-height: min(64vh, 620px);
  height: auto;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 20px 48px rgba(30, 20, 40, .16);
}

@media (max-width: 1120px) {
  .swmpro-layout { grid-template-columns: minmax(300px, 440px) minmax(360px, 1fr); gap: 18px; }
}

@media (max-width: 940px) {
  .swmpro-layout { grid-template-columns: 1fr; }
  .swmpro-preview-panel { order: -1; }
  .swmpro-preview-sticky { position: static; max-height: none; overflow: visible; }
  .swmpro-canvas-wrap canvas { max-height: 620px; }
}

@media (max-width: 640px) {
  .swmpro-app { margin: 20px auto; }
  .swmpro-header { padding: 22px 16px; border-radius: 22px; }
  .swmpro-card, .swmpro-preview-sticky { border-radius: 20px; padding: 15px; }
  .swmpro-grid-2, .swmpro-color-grid, .swmpro-template-grid, .swmpro-checks { grid-template-columns: 1fr; }
  .swmpro-preview-head { flex-direction: column; }
  .swmpro-preview-actions { justify-content: flex-start; }
  .swmpro-range-list label { grid-template-columns: 76px 1fr 34px; }
  .swmpro-canvas-wrap { padding: 10px; border-radius: 18px; }
  .swmpro-canvas-wrap canvas { border-radius: 16px; max-height: 540px; }
}



/* Keep preview compact so it remains visible while editing */
.swm-canvas-wrap {
  min-height: 0 !important;
  max-height: calc(100vh - 250px) !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.swm-canvas-wrap canvas {
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: calc(100vh - 285px) !important;
  object-fit: contain !important;
}

/* Make generated results more compact so controls remain usable */
.swm-results [data-swm-result-list] {
  max-height: 420px !important;
  overflow: auto !important;
  padding-right: 4px !important;
}

/* WordPress admin bar offset */
body.admin-bar .swm-sticky {
  top: 122px !important;
  max-height: calc(100vh - 140px) !important;
}

body.admin-bar .swm-canvas-wrap {
  max-height: calc(100vh - 280px) !important;
}

body.admin-bar .swm-canvas-wrap canvas {
  max-height: calc(100vh - 315px) !important;
}

@media (max-width: 980px) {
  .swm-sticky {
    position: static !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .swm-canvas-wrap,
  .swm-canvas-wrap canvas {
    max-height: none !important;
  }
}


/* V4.2 real sticky-preview fix
   The right preview column now stretches for the full height of the left controls,
   so sticky remains active while users scroll through generator, editor, templates,
   and design controls. */
.swm-pro-grid {
  display: grid !important;
  grid-template-columns: minmax(320px, 520px) minmax(420px, 1fr) !important;
  gap: 28px !important;
  align-items: stretch !important;
  position: relative !important;
}

.swm-controls {
  min-width: 0 !important;
  height: auto !important;
}

.swm-preview-panel {
  min-width: 0 !important;
  align-self: stretch !important;
  height: auto !important;
  min-height: 100% !important;
  position: relative !important;
  display: block !important;
}

/* Stick the preview card inside the full-height preview column */
.swm-sticky {
  position: sticky !important;
  top: 92px !important;
  z-index: 20 !important;
  align-self: start !important;
  max-height: calc(100vh - 110px) !important;
  overflow: auto !important;
  overscroll-behavior: contain !important;
}

/* Make the preview card fit the screen instead of pushing below the fold */
.swm-preview-head {
  gap: 12px !important;
}

.swm-preview-actions {
  gap: 8px !important;
}

.swm-preview-actions .swm-btn {
  min-height: 38px !important;
  padding: 9px 12px !important;
  font-size: 12px !important;
}

.swm-canvas-wrap {
  min-height: 0 !important;
  height: auto !important;
  max-height: calc(100vh - 265px) !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.swm-canvas-wrap canvas {
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: calc(100vh - 300px) !important;
  object-fit: contain !important;
}

/* Generated wishes stay scrollable so the left side doesn't become too tall */
.swm-results [data-swm-result-list],
.swm-result-list {
  max-height: 420px !important;
  overflow: auto !important;
  padding-right: 4px !important;
}

/* WordPress admin bar + theme header offset */
body.admin-bar .swm-sticky {
  top: 124px !important;
  max-height: calc(100vh - 145px) !important;
}

body.admin-bar .swm-canvas-wrap {
  max-height: calc(100vh - 300px) !important;
}

body.admin-bar .swm-canvas-wrap canvas {
  max-height: calc(100vh - 335px) !important;
}

/* If the theme header is sticky, this gives a little more breathing room */
@supports (position: sticky) {
  .swm-preview-panel .swm-sticky {
    will-change: transform;
  }
}

@media (max-width: 1080px) {
  .swm-pro-grid {
    grid-template-columns: 1fr !important;
    align-items: start !important;
  }

  .swm-preview-panel {
    order: -1 !important;
    min-height: auto !important;
  }

  .swm-sticky {
    position: static !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .swm-canvas-wrap,
  .swm-canvas-wrap canvas {
    max-height: none !important;
  }
}


/* V4.3 rebuilt sticky behavior based on Quote Maker layout */
.swm-pro {
  overflow: visible !important;
}

.swm-pro,
.swm-pro * {
  box-sizing: border-box !important;
}

.swm-pro-grid {
  display: grid !important;
  grid-template-columns: minmax(320px, 470px) minmax(420px, 1fr) !important;
  gap: 24px !important;
  align-items: start !important;
  overflow: visible !important;
  position: relative !important;
}

/* Left column: normal document scroll, no independent column scrolling */
.swm-controls {
  position: relative !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  min-width: 0 !important;
}

/* Right column: sticky itself, not only an inner child */
.swm-preview-panel {
  position: sticky !important;
  top: 112px !important;
  z-index: 30 !important;
  align-self: start !important;
  height: fit-content !important;
  max-height: calc(100vh - 130px) !important;
  overflow: hidden !important;
  min-width: 0 !important;
}

/* Disable old inner sticky logic to avoid parent-boundary conflict */
.swm-sticky {
  position: relative !important;
  top: auto !important;
  max-height: none !important;
  overflow: visible !important;
  z-index: auto !important;
}

/* Keep preview card usable inside viewport */
.swm-preview-head {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: space-between !important;
  gap: 12px !important;
  flex-wrap: wrap !important;
}

.swm-preview-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
}

.swm-preview-actions .swm-btn {
  min-height: 36px !important;
  padding: 8px 11px !important;
  font-size: 12px !important;
  border-radius: 12px !important;
}

.swm-canvas-wrap {
  min-height: 0 !important;
  height: auto !important;
  max-height: calc(100vh - 300px) !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.swm-canvas-wrap canvas {
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: calc(100vh - 330px) !important;
  object-fit: contain !important;
}

/* Generated results should not force the left column too far before templates */
.swm-results [data-swm-result-list],
.swm-result-list,
[data-swm-result-list] {
  max-height: 360px !important;
  overflow: auto !important;
  padding-right: 4px !important;
}

/* Template gallery scrolls inside its own panel, while preview remains sticky */
.swm-template-grid {
  max-height: 460px !important;
  overflow: auto !important;
  padding-right: 4px !important;
}

/* Admin bar + theme header */
body.admin-bar .swm-preview-panel {
  top: 142px !important;
  max-height: calc(100vh - 160px) !important;
}

body.admin-bar .swm-canvas-wrap {
  max-height: calc(100vh - 330px) !important;
}

body.admin-bar .swm-canvas-wrap canvas {
  max-height: calc(100vh - 360px) !important;
}

/* If theme containers add overflow hidden, this helps within the tool itself */
.entry-content .swm-pro,
.wp-block-post-content .swm-pro,
.site-main .swm-pro {
  overflow: visible !important;
}

@media (max-width: 1080px) {
  .swm-pro-grid {
    grid-template-columns: 1fr !important;
  }

  .swm-preview-panel {
    position: relative !important;
    top: auto !important;
    max-height: none !important;
    overflow: visible !important;
    order: -1 !important;
  }

  .swm-canvas-wrap,
  .swm-canvas-wrap canvas {
    max-height: none !important;
  }
}


/* V4.4 fixed live preview mode
   This bypasses theme/container sticky problems by fixing the preview to the viewport
   while keeping its original right-column width and position. */
@media (min-width: 1081px) {
  .swm-pro-grid {
    display: grid !important;
    grid-template-columns: minmax(320px, 520px) minmax(420px, 1fr) !important;
    gap: 28px !important;
    align-items: start !important;
    overflow: visible !important;
  }

  .swm-preview-panel {
    position: relative !important;
    min-width: 0 !important;
    align-self: start !important;
    overflow: visible !important;
  }

  .swm-preview-panel.swm-fixed-preview-placeholder {
    min-height: 720px !important;
  }

  .swm-preview-panel .swm-sticky {
    position: relative !important;
    top: auto !important;
    width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .swm-preview-panel.is-swm-fixed .swm-sticky {
    position: fixed !important;
    top: var(--swm-fixed-top, 120px) !important;
    left: var(--swm-fixed-left, auto) !important;
    width: var(--swm-fixed-width, 600px) !important;
    max-height: calc(100vh - var(--swm-fixed-top, 120px) - 22px) !important;
    overflow: auto !important;
    z-index: 999 !important;
  }

  .swm-preview-panel.is-swm-bottom .swm-sticky {
    position: absolute !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .swm-preview-panel.is-swm-fixed .swm-canvas-wrap,
  .swm-preview-panel.is-swm-bottom .swm-canvas-wrap {
    min-height: 0 !important;
    max-height: calc(100vh - var(--swm-fixed-top, 120px) - 210px) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
  }

  .swm-preview-panel.is-swm-fixed canvas,
  .swm-preview-panel.is-swm-bottom canvas {
    max-height: calc(100vh - var(--swm-fixed-top, 120px) - 245px) !important;
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
  }

  .swm-preview-actions .swm-btn {
    min-height: 36px !important;
    padding: 8px 11px !important;
    font-size: 12px !important;
  }
}

@media (max-width: 1080px) {
  .swm-preview-panel,
  .swm-preview-panel .swm-sticky {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
  }
}


/* V4.5 editor-mode root fix
   Root cause: the theme/page scroll was moving the whole tool, and CSS sticky/fixed was being constrained
   by parent containers. This version makes the tool itself a two-column editor:
   left controls scroll inside the tool; right preview remains always visible. */
:root {
  --swm-editor-offset: 132px;
  --swm-editor-min-height: 620px;
}

body.admin-bar {
  --swm-editor-offset: 164px;
}

/* Stop older sticky/fixed experiments from controlling the preview */
.swm-preview-panel,
.swm-preview-panel.is-swm-fixed,
.swm-preview-panel.is-swm-bottom,
.swm-preview-panel.swm-fixed-preview-placeholder,
.swm-preview-panel .swm-sticky,
.swm-preview-panel.is-swm-fixed .swm-sticky,
.swm-preview-panel.is-swm-bottom .swm-sticky {
  position: static !important;
  top: auto !important;
  bottom: auto !important;
  left: auto !important;
  width: auto !important;
  max-height: none !important;
  overflow: visible !important;
  z-index: auto !important;
}

/* The whole working area behaves like an app/editor */
.swm-pro-grid {
  display: grid !important;
  grid-template-columns: minmax(320px, 520px) minmax(430px, 1fr) !important;
  gap: 28px !important;
  align-items: stretch !important;
  height: calc(100vh - var(--swm-editor-offset)) !important;
  min-height: var(--swm-editor-min-height) !important;
  max-height: 920px !important;
  overflow: hidden !important;
  position: sticky !important;
  top: calc(var(--swm-editor-offset) - 96px) !important;
}

/* Left side is the only side that scrolls */
.swm-controls {
  height: 100% !important;
  max-height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding-right: 8px !important;
  min-width: 0 !important;
  overscroll-behavior: contain !important;
  scrollbar-width: thin;
}

/* Right side stays in place naturally because the outer editor doesn't scroll */
.swm-preview-panel {
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
  min-width: 0 !important;
  align-self: stretch !important;
}

.swm-sticky {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.swm-preview-head {
  flex: 0 0 auto !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: flex-start !important;
  gap: 12px !important;
  flex-wrap: wrap !important;
  margin-bottom: 12px !important;
}

.swm-preview-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
}

.swm-preview-actions .swm-btn,
.swm-preview-head .swm-btn {
  min-height: 36px !important;
  padding: 8px 11px !important;
  font-size: 12px !important;
  border-radius: 12px !important;
}

.swm-canvas-wrap {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 18px !important;
}

.swm-canvas-wrap canvas {
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
}

/* Generated wishes and templates can also scroll inside their cards */
.swm-results [data-swm-result-list],
.swm-result-list,
[data-swm-result-list] {
  max-height: 330px !important;
  overflow-y: auto !important;
  padding-right: 4px !important;
}

.swm-template-grid {
  max-height: 520px !important;
  overflow-y: auto !important;
  padding-right: 4px !important;
}

/* Better scrollbar on left controls */
.swm-controls::-webkit-scrollbar,
.swm-template-grid::-webkit-scrollbar,
[data-swm-result-list]::-webkit-scrollbar {
  width: 8px;
}

.swm-controls::-webkit-scrollbar-thumb,
.swm-template-grid::-webkit-scrollbar-thumb,
[data-swm-result-list]::-webkit-scrollbar-thumb {
  background: rgba(225, 29, 119, .22);
  border-radius: 999px;
}

.swm-controls::-webkit-scrollbar-track,
.swm-template-grid::-webkit-scrollbar-track,
[data-swm-result-list]::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, .04);
  border-radius: 999px;
}

/* When screen is smaller, return to normal stacked flow */
@media (max-width: 1080px) {
  .swm-pro-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    position: relative !important;
    top: auto !important;
  }

  .swm-preview-panel {
    order: -1 !important;
    height: auto !important;
    overflow: visible !important;
  }

  .swm-sticky {
    height: auto !important;
    overflow: visible !important;
  }

  .swm-controls {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding-right: 0 !important;
  }

  .swm-canvas-wrap {
    min-height: 360px !important;
    max-height: none !important;
  }

  .swm-canvas-wrap canvas {
    max-height: none !important;
  }
}


/* V4.6 TRUE root-cause fix for the real Wish Maker classes.
   The visible plugin uses swmpro-* classes, not swm-* classes.
   This makes the actual right preview column sticky like the Quote Maker. */

.swmpro-app,
.swmpro-app * {
  box-sizing: border-box;
}

.swmpro-app {
  overflow: visible !important;
}

/* Same stable structure as Quote Maker */
.swmpro-layout {
  display: grid !important;
  grid-template-columns: minmax(330px, 480px) minmax(420px, 1fr) !important;
  gap: 24px !important;
  align-items: start !important;
  overflow: visible !important;
  position: relative !important;
}

/* Left controls scroll naturally with the page */
.swmpro-sidebar {
  display: grid !important;
  gap: 16px !important;
  min-width: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

/* This is the key: make the grid item itself sticky, not the small inner box */
.swmpro-preview-panel {
  position: sticky !important;
  top: 118px !important;
  align-self: start !important;
  min-width: 0 !important;
  height: fit-content !important;
  z-index: 50 !important;
  overflow: visible !important;
}

/* Inner preview should not create a short sticky boundary */
.swmpro-preview-sticky {
  position: relative !important;
  top: auto !important;
  max-height: calc(100vh - 138px) !important;
  overflow: auto !important;
  padding: 18px !important;
}

/* Keep preview compact so it stays visible */
.swmpro-preview-head {
  display: flex !important;
  justify-content: space-between !important;
  align-items: flex-start !important;
  gap: 12px !important;
  flex-wrap: wrap !important;
  margin-bottom: 12px !important;
}

.swmpro-preview-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  justify-content: flex-end !important;
}

.swmpro-preview-actions .swmpro-btn,
.swmpro-preview-actions button {
  min-height: 36px !important;
  padding: 8px 11px !important;
  font-size: 12px !important;
  border-radius: 12px !important;
}

.swmpro-canvas-wrap {
  min-height: 0 !important;
  max-height: calc(100vh - 315px) !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 14px !important;
}

.swmpro-canvas-wrap canvas {
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: calc(100vh - 350px) !important;
  object-fit: contain !important;
}

/* Generated wishes and templates should not push the left side too far */
.swmpro-results {
  max-height: 360px !important;
  overflow-y: auto !important;
  padding-right: 4px !important;
}

.swmpro-template-grid {
  max-height: 520px !important;
  overflow-y: auto !important;
  padding-right: 4px !important;
}

/* Admin bar + SayMuse sticky header offset */
body.admin-bar .swmpro-preview-panel {
  top: 144px !important;
}

body.admin-bar .swmpro-preview-sticky {
  max-height: calc(100vh - 164px) !important;
}

body.admin-bar .swmpro-canvas-wrap {
  max-height: calc(100vh - 340px) !important;
}

body.admin-bar .swmpro-canvas-wrap canvas {
  max-height: calc(100vh - 375px) !important;
}

/* Prevent older experimental classes from affecting anything if cached JS adds them */
.swmpro-preview-panel.is-swm-fixed,
.swmpro-preview-panel.is-swm-bottom,
.swmpro-preview-panel.swm-fixed-preview-placeholder {
  position: sticky !important;
  top: 118px !important;
  left: auto !important;
  width: auto !important;
  bottom: auto !important;
}

body.admin-bar .swmpro-preview-panel.is-swm-fixed,
body.admin-bar .swmpro-preview-panel.is-swm-bottom,
body.admin-bar .swmpro-preview-panel.swm-fixed-preview-placeholder {
  top: 144px !important;
}

/* Smaller screens: stack normally */
@media (max-width: 1080px) {
  .swmpro-layout {
    grid-template-columns: 1fr !important;
  }

  .swmpro-preview-panel {
    position: static !important;
    top: auto !important;
    order: -1 !important;
  }

  .swmpro-preview-sticky {
    max-height: none !important;
    overflow: visible !important;
  }

  .swmpro-canvas-wrap,
  .swmpro-canvas-wrap canvas {
    max-height: none !important;
  }
}
