/* =========================================================================
 * StudioFlow DriveGallery — Unified v5.0 Zero-Copy Motion + Full v4 System
 * =========================================================================
 * - Tier 1 (`html[data-sf-ui-tier="v5"]`): Zero-Copy Motion Front Door (26 words,
 *   Conic Specular Input Capsule, Spring Segmented Tabs, Morphing Device Stage)
 *   + 1-Tap Expandable Full Studio System Drawer (`data-sf-v5-drawer="1"`).
 * - Tier 2 (`html[data-sf-adaptive-ui="1"]` without `v5`): Full 2-Column Adaptive v4.0
 * - Tier 3 (Classic): All 38 Studio Controls visible.
 * - 0% impact on Mode B Client Gallery (`#clientGalleryRoot`).
 * ========================================================================= */

@property --sf-beam-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

/* =========================================================================
 * V5.0 ZERO-COPY MOTION FRONT DOOR (`#sfV5Stage`)
 * ========================================================================= */
.sf-v5-stage {
  display: none;
}

html[data-sf-ui-tier="v5"] #builderShell .sf-v5-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 980px;
  margin: 0 auto;
  padding: 26px 16px 30px;
  position: relative;
}

/* Hide classic hero & collapse heavy 2-col builder until user expands Full System OR generates a link */
html[data-sf-ui-tier="v5"] #builderShell .builder-hero-strip,
html[data-sf-ui-tier="v5"] #builderShell .sf-clarity-hero,
html[data-sf-ui-tier="v5"] #academyQuickStartStrip,
html[data-sf-ui-tier="v5"] .sfa-quickstart-strip {
  display: none !important;
}

html[data-sf-ui-tier="v5"]:not([data-sf-v5-drawer="1"]):not([data-sf-has-result="1"]) #builderShell .builder-grid {
  display: none !important;
}

/* When `#resultCard` is ready in v5 mode (without full drawer open), show ONLY `#resultCard` cleanly centered! */
html[data-sf-ui-tier="v5"][data-sf-has-result="1"]:not([data-sf-v5-drawer="1"]) #builderShell .builder-grid {
  display: block !important;
  max-width: 760px;
  margin: 0 auto 40px;
}
html[data-sf-ui-tier="v5"][data-sf-has-result="1"]:not([data-sf-v5-drawer="1"]) #builderShell .builder-preview-col,
html[data-sf-ui-tier="v5"][data-sf-has-result="1"]:not([data-sf-v5-drawer="1"]) #builderShell .builder-form-col > .card:not(#resultCard) {
  display: none !important;
}

/* Smooth slide-down animation when Full System Drawer (`⚙️ ตั้งค่าเต็มระบบ`) opens */
html[data-sf-ui-tier="v5"][data-sf-v5-drawer="1"] #builderShell .builder-grid {
  animation: sfDrawerReveal 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
  margin-top: 8px;
}
@keyframes sfDrawerReveal {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Clean Topbar in v5 & v4 Adaptive modes */
html[data-sf-adaptive-ui="1"] #builderTopbar #btnOpenLiveStation,
html[data-sf-adaptive-ui="1"] #builderTopbar #btnOpenVideoAcademy,
html[data-sf-adaptive-ui="1"] #builderTopbar #btnOpenUserGuide,
html[data-sf-adaptive-ui="1"] #builderTopbar #btnOpenUpgradeModal,
html[data-sf-adaptive-ui="1"] #builderTopbar #btnOpenSetup,
html[data-sf-adaptive-ui="1"][data-sf-persona-mode="quick"] #sfSourceModeBar,
html[data-sf-adaptive-ui="1"][data-sf-empty-url="1"] #coverPickerBox {
  display: none !important;
}

html[data-sf-adaptive-ui="1"] #sfTopbarMoreToolsBtn,
html[data-sf-adaptive-ui="1"] #sfTopbarFullSystemBtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

#sfTopbarFullSystemBtn {
  display: none;
  background: linear-gradient(135deg, #2563EB 0%, #1849D6 100%);
  border-color: #1849D6;
  color: #FFFFFF;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(24, 73, 214, 0.24);
}
#sfTopbarFullSystemBtn:hover {
  background: linear-gradient(135deg, #1D4ED8 0%, #1E40AF 100%);
}

html[data-sf-adaptive-ui="1"] #builderTopbar #sfTopbarMoreToolsBtn {
  background: #EFF6FF;
  border-color: #93C5FD;
  color: #1849D6;
  font-weight: 700;
}
html[data-workspace-night="1"][data-sf-adaptive-ui="1"] #builderTopbar #sfTopbarMoreToolsBtn {
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(96, 165, 250, 0.45);
  color: #93C5FD;
}

/* V5 Hero Cloud Pill + Minimal Headline */
.sf-v5-cloud-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--surface, #FFFFFF);
  border: 1px solid var(--border, #E2E8F0);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #64748B);
  margin-bottom: 12px;
}
html[data-workspace-night="1"] .sf-v5-cloud-pill {
  background: #111827;
  border-color: #24324A;
  color: #94A3B8;
}
.sf-v5-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.18);
  animation: sfPulseDot 2s ease-in-out infinite;
}
@keyframes sfPulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.72; }
}

.sf-v5-h1 {
  margin: 0 0 22px;
  text-align: center;
  font-size: clamp(27px, 4.4vw, 48px);
  font-weight: 800;
  letter-spacing: -0.032em;
  line-height: 1.14;
  color: var(--ink, #0B1324);
}
.sf-v5-h1 .sf-v5-grad {
  background: linear-gradient(135deg, #1849D6 0%, #0077ED 55%, #0EA5E9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
html[data-workspace-night="1"] .sf-v5-h1 .sf-v5-grad {
  background: linear-gradient(135deg, #60A5FA 0%, #38BDF8 65%, #A5F3FC 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Conic Specular Spotlight Command Bar */
.sf-v5-cmd-shell {
  width: 100%;
  max-width: 720px;
  padding: 2px;
  border-radius: 22px;
  background: conic-gradient(
    from var(--sf-beam-angle),
    rgba(24, 73, 214, 0.14) 0%,
    rgba(24, 73, 214, 0.14) 68%,
    #2563EB 82%,
    #38BDF8 91%,
    rgba(24, 73, 214, 0.14) 100%
  );
  animation: sfSpinBeam 5.5s linear infinite;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(24, 73, 214, 0.08);
  margin-bottom: 12px;
}
@keyframes sfSpinBeam {
  to { --sf-beam-angle: 360deg; }
}

.sf-v5-cmd-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface, #FFFFFF);
  border-radius: 20px;
  padding: 8px 8px 8px 14px;
}
html[data-workspace-night="1"] .sf-v5-cmd-inner {
  background: #111827;
}

.sf-v5-cmd-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.sf-v5-cloud-ico {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: rgba(24, 73, 214, 0.09);
  color: #1849D6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
html[data-workspace-night="1"] .sf-v5-cloud-ico {
  background: rgba(59, 130, 246, 0.18);
  color: #60A5FA;
}
.sf-v5-csvg {
  position: absolute;
  width: 19px;
  height: 19px;
  opacity: 0;
  transform: translateY(9px) scale(0.85);
  transition: opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1), transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}
.sf-v5-csvg.is-shown {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.sf-v5-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink, #0B1324);
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 500;
}
.sf-v5-input::placeholder {
  color: var(--muted, #64748B);
}

.sf-v5-cta {
  height: 48px;
  padding: 0 22px;
  border-radius: 14px;
  border: 0;
  background: linear-gradient(135deg, #2563EB 0%, #1849D6 60%, #1E40AF 100%);
  color: #FFFFFF;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(24, 73, 214, 0.34);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}
.sf-v5-cta:hover {
  transform: scale(1.025);
  box-shadow: 0 12px 28px rgba(24, 73, 214, 0.44);
}
.sf-v5-cta:active {
  transform: scale(0.97);
}

/* Quick Sub-Action Row (Demo + Local SSD + Live FTP shortcuts) */
.sf-v5-quick-subrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.sf-v5-subpill {
  border: 1px solid rgba(24, 73, 214, 0.22);
  background: rgba(24, 73, 214, 0.06);
  color: #1849D6;
  border-radius: 999px;
  padding: 5px 13px;
  font-family: inherit;
  font-size: 12.2px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: transform 0.16s ease, background-color 0.16s ease;
}
.sf-v5-subpill:hover {
  background: rgba(24, 73, 214, 0.13);
  transform: translateY(-1px);
}
html[data-workspace-night="1"] .sf-v5-subpill {
  border-color: rgba(96, 165, 250, 0.32);
  background: rgba(37, 99, 235, 0.16);
  color: #93C5FD;
}

/* Spring Sliding Segmented Control */
.sf-v5-seg-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
  max-width: 540px;
  padding: 4px;
  border-radius: 16px;
  background: #E8ECF4;
  border: 1px solid rgba(15, 23, 42, 0.06);
  margin-bottom: 14px;
}
html[data-workspace-night="1"] .sf-v5-seg-track {
  background: #162033;
  border-color: #2B3B55;
}

.sf-v5-seg-glider {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 4);
  border-radius: 12px;
  background: linear-gradient(135deg, #2563EB 0%, #1849D6 100%);
  box-shadow: 0 6px 16px rgba(24, 73, 214, 0.32);
  transform: translateX(calc(var(--v5-seg-idx, 0) * 100%));
  transition: transform 0.46s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 0;
}

.sf-v5-seg-btn {
  position: relative;
  z-index: 1;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--ink, #0B1324);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 12px;
  white-space: nowrap;
  transition: color 0.22s ease;
}
.sf-v5-seg-btn.is-active {
  color: #FFFFFF;
}

/* Tactile 2-Word Feature Chips + Prominent Full-System Expand Button */
.sf-v5-chips-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.sf-v5-chip {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border, #CBD5E1);
  background: var(--surface, #FFFFFF);
  color: var(--muted, #64748B);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}
html[data-workspace-night="1"] .sf-v5-chip {
  background: #111827;
  border-color: #2B3B55;
  color: #94A3B8;
}
.sf-v5-chip:hover {
  transform: translateY(-1px);
}
.sf-v5-chip.is-on {
  border-color: #1849D6;
  background: rgba(24, 73, 214, 0.1);
  color: #1849D6;
}
html[data-workspace-night="1"] .sf-v5-chip.is-on {
  border-color: #60A5FA;
  background: rgba(37, 99, 235, 0.24);
  color: #93C5FD;
}
.sf-v5-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
}
.sf-v5-chip.is-on .sf-v5-chip-dot {
  opacity: 1;
}

/* THE KEY BRIDGE BUTTON: "⚙️ ตั้งค่าเต็มระบบ ▾" (Prominent Solid Royal Blue Outline/Fill) */
.sf-v5-full-drawer-btn {
  height: 36px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1.5px solid #1849D6;
  background: #EFF6FF;
  color: #1849D6;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 3px 10px rgba(24, 73, 214, 0.12);
  transition: transform 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}
.sf-v5-full-drawer-btn:hover,
.sf-v5-full-drawer-btn.is-open {
  background: #1849D6;
  color: #FFFFFF;
  transform: translateY(-1px);
}
html[data-workspace-night="1"] .sf-v5-full-drawer-btn {
  background: rgba(37, 99, 235, 0.2);
  border-color: #60A5FA;
  color: #BFDBFE;
}
html[data-workspace-night="1"] .sf-v5-full-drawer-btn.is-open {
  background: #2563EB;
  color: #FFFFFF;
}

/* Morphing Device Stage (9:16 iPhone <-> 16:9 Event LED Wall) */
.sf-v5-hw-frame {
  position: relative;
  width: 326px;
  height: 576px;
  border-radius: 44px;
  padding: 10px;
  background: linear-gradient(145deg, #2C2C30 0%, #151518 50%, #3A3A40 100%);
  box-shadow: 0 28px 64px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.14) inset;
  transition: width 0.62s cubic-bezier(0.22, 1, 0.36, 1), height 0.62s cubic-bezier(0.22, 1, 0.36, 1), border-radius 0.62s cubic-bezier(0.22, 1, 0.36, 1);
}
html[data-sf-persona-mode="event"] .sf-v5-hw-frame {
  width: min(790px, 94vw);
  height: 446px;
  border-radius: 26px;
}

.sf-v5-island {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  height: 25px;
  min-width: 98px;
  padding: 0 12px;
  border-radius: 999px;
  background: #000000;
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: all 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sf-v5-island.is-green {
  background: #059669;
  min-width: 176px;
}

.sf-v5-viewport {
  width: 100%;
  height: 100%;
  border-radius: 35px;
  overflow: hidden;
  background: #0B0F17;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: border-radius 0.62s cubic-bezier(0.22, 1, 0.36, 1);
}
html[data-sf-persona-mode="event"] .sf-v5-viewport {
  border-radius: 18px;
}

.sf-v5-hero {
  position: relative;
  height: 46%;
  overflow: hidden;
  transition: height 0.58s cubic-bezier(0.22, 1, 0.36, 1);
}
html[data-sf-persona-mode="event"] .sf-v5-hero {
  height: 100%;
}
.sf-v5-hero > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: sfKenBurns 12s ease-in-out infinite alternate;
}
@keyframes sfKenBurns {
  from { transform: scale(1.02); }
  to { transform: scale(1.08); }
}
.sf-v5-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.26) 0%, rgba(0,0,0,0.08) 45%, rgba(11,15,23,0.9) 100%);
}

.sf-v5-ai-pill {
  position: absolute;
  top: 42px;
  left: 13px;
  z-index: 8;
  padding: 4px 10px 4px 5px;
  border-radius: 999px;
  background: rgba(24, 73, 214, 0.88);
  color: #FFFFFF;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 0.28s ease, transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sf-v5-ai-pill.is-shown {
  opacity: 1;
  transform: scale(1);
}
.sf-v5-ai-ava {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  border: 1.5px solid #93C5FD;
}
.sf-v5-ai-ava img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sf-v5-ai-ava::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #38BDF8;
  animation: sfLaser 1.5s ease-in-out infinite alternate;
}
@keyframes sfLaser {
  0% { top: 2px; }
  100% { top: 17px; }
}

.sf-v5-bgm-pill {
  position: absolute;
  top: 42px;
  right: 13px;
  z-index: 8;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #FFFFFF;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 0.28s ease, transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sf-v5-bgm-pill.is-shown {
  opacity: 1;
  transform: scale(1);
}
.sf-v5-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 11px;
}
.sf-v5-eq i {
  width: 2.5px;
  background: #38BDF8;
  border-radius: 2px;
  animation: sfEqBar 0.7s ease-in-out infinite alternate;
}
.sf-v5-eq i:nth-child(2) { animation-delay: 0.16s; }
.sf-v5-eq i:nth-child(3) { animation-delay: 0.3s; }
.sf-v5-eq i:nth-child(4) { animation-delay: 0.1s; }
@keyframes sfEqBar {
  from { height: 3px; }
  to { height: 11px; }
}

.sf-v5-caption {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 12px;
  z-index: 6;
  color: #FFFFFF;
  transition: bottom 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
html[data-sf-persona-mode="event"] .sf-v5-caption {
  bottom: 92px;
  left: 20px;
}
.sf-v5-caption strong {
  display: block;
  font-size: 16.5px;
  font-weight: 800;
}
.sf-v5-caption span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.78);
}

.sf-v5-led-strip,
.sf-v5-led-qr {
  display: none;
}
html[data-sf-persona-mode="event"] .sf-v5-led-strip {
  position: absolute;
  left: 18px;
  bottom: 16px;
  z-index: 10;
  display: flex;
  gap: 8px;
}
.sf-v5-led-thumb {
  width: 62px;
  height: 62px;
  border-radius: 11px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.86);
}
.sf-v5-led-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
html[data-sf-persona-mode="event"] .sf-v5-led-qr {
  position: absolute;
  right: 18px;
  bottom: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.95);
  color: #0B1324;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}
.sf-v5-led-qr-svg {
  width: 58px;
  height: 58px;
}
.sf-v5-led-qr-svg svg {
  width: 100%;
  height: 100%;
}
.sf-v5-led-qr strong {
  display: block;
  font-size: 12.5px;
  font-weight: 800;
  color: #1849D6;
}
.sf-v5-led-qr small {
  font-size: 10.5px;
  font-weight: 600;
  color: #475569;
}

.sf-v5-grid {
  flex: 1;
  background: #FFFFFF;
  padding: 9px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  overflow: hidden;
}
html[data-sf-persona-mode="event"] .sf-v5-grid,
html[data-sf-persona-mode="event"] .sf-v5-save-pill {
  display: none;
}

.sf-v5-pcard {
  position: relative;
  border-radius: 11px;
  overflow: hidden;
  background: #E2E8F0;
}
.sf-v5-pcard img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.sf-v5-pcard.is-ai {
  box-shadow: 0 0 0 2.5px #2563EB;
}
.sf-v5-heart {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #E11D48;
  color: #FFFFFF;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sf-v5-heart.is-shown {
  transform: scale(1);
}
.sf-v5-wm {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(-32deg, rgba(255,255,255,0.25) 0 2px, transparent 2px 24px);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 5px;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sf-v5-wm.is-shown {
  opacity: 1;
}
.sf-v5-wm span {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  color: #FDE047;
  font-size: 10px;
  font-weight: 800;
}

.sf-v5-save-pill {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  height: 36px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563EB 0%, #1849D6 100%);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: 0 6px 16px rgba(24, 73, 214, 0.35);
}

/* =========================================================================
 * V4.0 FULL BUILDER & ROYAL BLUE BANNER STYLES (Shown when Drawer opens or in v4 mode)
 * ========================================================================= */
.sf-adaptive-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1E3A8A 0%, #1849D6 52%, #2563EB 100%);
  border: 1px solid rgba(37, 99, 235, 0.9);
  box-shadow: 0 8px 22px rgba(24, 73, 214, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.sf-adaptive-mode-bar-copy {
  font-size: 13.5px;
  font-weight: 700;
  color: #FFFFFF;
}
.sf-adaptive-view-toggle {
  border: 2px solid #FFFFFF;
  background: #FFFFFF;
  color: #1849D6;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(11, 19, 36, 0.2);
  white-space: nowrap;
}
.sf-adaptive-view-toggle:hover {
  background: #EFF6FF;
}

html[data-sf-adaptive-ui="1"]:not([data-sf-ui-tier="v5"]) #builderShell .builder-hero-strip {
  display: none !important;
}
.sf-clarity-hero {
  display: none;
}
html[data-sf-adaptive-ui="1"]:not([data-sf-ui-tier="v5"]) #builderShell .sf-clarity-hero {
  display: block;
  text-align: center;
  padding: 18px 0 22px;
}

.sf-no-install-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 999px;
  background-color: #ECFDF5;
  color: #047857;
  border: 1px solid #A7F3D0;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 10px;
}
.sf-clarity-hero h1 {
  margin: 0 auto 8px;
  max-width: 780px;
  font-size: clamp(23px, 3vw, 34px);
  font-weight: 800;
  line-height: 1.24;
  color: var(--ink, #0B1324);
}
.sf-clarity-hero p {
  margin: 0 auto 18px;
  max-width: 640px;
  font-size: 15px;
  color: var(--muted, #475569);
}
.sf-easy-steps {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.sf-easy-step-card {
  background: var(--surface, #FFFFFF);
  border: 1px solid var(--border, #DCE4F0);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
}
.sf-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563EB 0%, #1849D6 100%);
  color: #FFFFFF;
  font-style: normal;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sf-easy-step-card strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink, #0B1324);
}
.sf-easy-step-card span {
  display: block;
  font-size: 12.2px;
  color: var(--muted, #64748B);
}

.sf-persona-block {
  display: none;
}
html[data-sf-adaptive-ui="1"] .sf-persona-block {
  display: block;
  margin-bottom: 18px;
}
.sf-persona-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.sf-persona-head strong {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--ink, #0B1324);
}
.sf-persona-head span {
  font-size: 12.5px;
  color: var(--muted, #64748B);
}
.sf-persona-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.sf-persona-btn {
  padding: 12px 11px;
  border-radius: 13px;
  border: 1.5px solid #CBD5E1;
  background: var(--surface, #FFFFFF);
  color: var(--ink, #0B1324);
  text-align: left;
  cursor: pointer;
}
html[data-workspace-night="1"] .sf-persona-btn {
  background: #0F172A;
  border-color: #2B3B55;
  color: #F8FAFC;
}
.sf-persona-btn.is-active {
  border-color: #1849D6;
  background: linear-gradient(135deg, #1E40AF 0%, #1849D6 55%, #2563EB 100%);
  color: #FFFFFF;
  box-shadow: 0 8px 20px rgba(24, 73, 214, 0.28);
}
.sf-persona-btn strong {
  display: block;
  font-size: 13.8px;
  font-weight: 800;
  margin-bottom: 3px;
}
.sf-persona-btn small {
  display: block;
  font-size: 11.8px;
  color: var(--muted, #64748B);
}
.sf-persona-btn.is-active strong,
.sf-persona-btn.is-active small {
  color: #FFFFFF;
}

.sf-context-panel {
  display: none;
}
html[data-sf-adaptive-ui="1"] .sf-context-panel {
  display: block;
  margin: 18px 0 14px;
  padding-top: 16px;
  border-top: 1px solid var(--border, #E2E8F0);
}
.sf-context-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.sf-context-head strong {
  font-size: 14.8px;
  font-weight: 800;
  color: var(--ink, #0B1324);
}
.sf-hidden-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: #ECFDF5;
  color: #047857;
  font-size: 11.8px;
  font-weight: 700;
}
.sf-context-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 2px;
  border-bottom: 1px solid var(--border, #E2E8F0);
  font-size: 14px;
  color: var(--ink, #0B1324);
}
.sf-context-row:last-child { border-bottom: 0; }
.sf-context-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
  min-width: 210px;
}
.sf-context-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #1849D6;
}
.sf-inline-mini-input {
  width: 126px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #CBD5E1);
  background: var(--surface, #FFFFFF);
  color: var(--ink, #0B1324);
  font-size: 13px;
  text-align: center;
}
.sf-live-station-shortcut {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid #10B981;
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

html[data-sf-adaptive-ui="1"] .sf-adv-hidden {
  display: none !important;
}
.sf-optional-drawer-bar { display: none; }
html[data-sf-adaptive-ui="1"] .sf-optional-drawer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 16px;
  padding: 12px 16px;
  border-radius: 13px;
  border: 1.5px solid #BFDBFE;
  background: #F0F6FF;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  color: #1E3A8A;
}
#sfOptDrawerIndicator {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  background: #1849D6;
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 800;
}
html[data-sf-adaptive-ui="1"] #builderShell[data-sf-adv-expanded="1"] .sf-adv-hidden {
  display: block !important;
}
html[data-sf-adaptive-ui="1"] #builderShell[data-sf-adv-expanded="1"] .two-col.sf-adv-hidden {
  display: grid !important;
}
html[data-sf-adaptive-ui="1"] #builderShell[data-sf-adv-expanded="1"] .card-step-head.sf-adv-hidden,
html[data-sf-adaptive-ui="1"] #builderShell[data-sf-adv-expanded="1"] .whitelabel-shield-note.sf-adv-hidden {
  display: flex !important;
}
html[data-sf-adaptive-ui="1"] #builderShell:not([data-sf-adv-expanded="1"]) .two-col:has(#inpTitle) {
  grid-template-columns: 1fr !important;
}

html[data-sf-adaptive-ui="1"] #builderShell #btnInspectFolder {
  background: linear-gradient(135deg, #2563EB 0%, #1849D6 100%) !important;
  border-color: #1849D6 !important;
  color: #FFFFFF !important;
  font-weight: 700 !important;
}
html[data-sf-adaptive-ui="1"] #builderShell #btnGenerateLink {
  min-height: 54px;
  font-size: 16px;
  font-weight: 800;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563EB 0%, #1849D6 55%, #1E3A8A 100%) !important;
  border-color: #1849D6 !important;
  color: #FFFFFF !important;
  box-shadow: 0 10px 26px rgba(24, 73, 214, 0.34) !important;
}

#prevMiniGrid:has(.sf-sample-mini-card) {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 6px !important;
}
.sf-sample-mini-card {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  overflow: hidden;
  background: #0F172A;
}
.sf-sample-mini-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.sf-sample-mini-badge {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(11, 19, 36, 0.82);
  color: #FFFFFF;
  font-size: 9.5px;
  font-weight: 700;
}

/* Responsive Mobile Polish (`320px–640px` Zero Overflow) */
@media (max-width: 900px) {
  .sf-easy-steps { grid-template-columns: 1fr; gap: 8px; }
  .sf-persona-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  html[data-sf-adaptive-ui="1"] #builderTopbar .studio-badge-text span,
  html[data-sf-adaptive-ui="1"] #builderTopbar #btnLoadSampleNow {
    display: none;
  }
  html[data-sf-adaptive-ui="1"] #builderTopbar .studio-badge-text strong {
    font-size: 13px;
    white-space: nowrap;
  }
  html[data-sf-adaptive-ui="1"] #builderTopbar .topbar-actions {
    gap: 5px;
  }
  .sf-v5-cmd-inner {
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    gap: 8px;
  }
  .sf-v5-cta {
    width: 100%;
    height: 46px;
  }
  .sf-v5-seg-btn {
    font-size: 12px;
    gap: 4px;
    padding: 0 3px;
  }
  .sf-v5-hw-frame {
    width: min(312px, 90vw);
    height: 536px;
  }
  html[data-sf-persona-mode="event"] .sf-v5-hw-frame {
    width: 92vw;
    height: 248px;
    border-radius: 20px;
    padding: 7px;
  }
  html[data-sf-persona-mode="event"] .sf-v5-caption {
    bottom: 70px;
    left: 14px;
  }
  html[data-sf-persona-mode="event"] .sf-v5-led-thumb {
    width: 44px;
    height: 44px;
  }
  html[data-sf-persona-mode="event"] .sf-v5-led-qr-svg {
    width: 42px;
    height: 42px;
  }
}
