
/* Mobile Studio recovery: one header strip, one tool drawer, one Elements
   catalogue. Loaded last to override legacy UI modules and old tablet CSS. */
@media (max-width:767px) {
  #ms-studio-master-modal .studio-header-stack {
    height:56px!important;min-height:56px!important;max-height:56px!important;
    overflow:hidden!important;flex:0 0 56px!important
  }
  #ms-studio-master-modal .studio-header-stack .studio-identity-bar{
    height:56px!important;min-height:56px!important;max-height:56px!important;
    padding:5px 8px!important;gap:4px!important;flex-wrap:nowrap!important;
    overflow:hidden!important
  }
  #ms-studio-master-modal .studio-header-stack .studio-brand-logo,
  #ms-studio-master-modal .studio-header-stack .studio-brand-mark,
  #ms-studio-master-modal .studio-header-stack img[alt="MarketSync"] {
    display:none!important;visibility:hidden!important;
    width:0!important;min-width:0!important;max-width:0!important;
    height:0!important;max-height:0!important;
  }
  #ms-studio-master-modal .studio-header-stack .studio-identity-main {max-width:64px!important;flex:0 0 64px!important}
  #ms-studio-master-modal .studio-header-stack .studio-primary-actions {
    flex:1 1 auto!important;min-width:0!important;max-width:calc(100% - 68px)!important;
    gap:3px!important;overflow:hidden!important;justify-content:flex-end!important
  }
  #ms-studio-master-modal #studio-tool-panel.ms-studio-mobile-open {
    position:absolute!important;left:0!important;right:0!important;top:56px!important;
    bottom:98px!important;width:100%!important;max-width:100%!important;
    max-height:calc(100dvh - 154px)!important;overflow:hidden!important;
    display:flex!important;flex-direction:column!important;
  }
  #ms-studio-master-modal #studio-tool-panel-content{
    flex:1 1 auto!important;min-height:0!important;width:100%!important;
    overflow-x:hidden!important;overflow-y:auto!important;
    overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
  }
  #ms-studio-master-modal .ms-studio-elements-panel,
  #ms-studio-master-modal #studio-element-body,
  #ms-studio-master-modal #studio-premade-library,
  #ms-studio-master-modal .ms-curated-category-detail,
  #ms-studio-master-modal .ms-curated-home {
    display:block!important;width:100%!important;min-width:0!important;max-width:100%!important;
    box-sizing:border-box!important;float:none!important;clear:both!important;
  }
  #ms-studio-master-modal .ms-curated-categories,
  #ms-studio-master-modal .studio-featured-layouts {
    width:100%!important;max-width:100%!important;position:static!important;
    float:none!important;clear:both!important;margin:0 0 16px!important;
  }
  #ms-studio-master-modal .ms-curated-category-tiles {
    display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;
    gap:14px 8px!important;position:static!important;width:100%!important;
  }
  #ms-studio-master-modal .ms-curated-category-tiles button{
    display:flex!important;flex-direction:column!important;align-items:center!important;
    justify-content:flex-start!important;position:relative!important;
    width:100%!important;min-width:0!important;gap:6px!important;
    padding:0!important;border:0!important;box-shadow:none!important;
    background:transparent!important;white-space:normal!important
  }
  #ms-studio-master-modal .ms-curated-category-tiles button>span:last-child{
    font-size:11px!important;line-height:1.25!important;
    overflow-wrap:anywhere!important;text-align:center!important;
  }
  #ms-studio-master-modal .ms-curated-category-art {
    display:grid!important;place-items:center!important;
    width:min(58px,100%)!important;height:auto!important;
    aspect-ratio:1!important;max-width:100%!important;
    position:relative!important;flex:0 0 auto!important;
  }
  #ms-studio-master-modal .studio-featured-layout-grid {
    display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:10px!important;width:100%!important;
  }
  #ms-studio-master-modal .studio-frame-photo-help {
    display:grid;gap:10px;margin-top:12px;padding:12px;border-radius:12px;
    border:1px solid rgba(99,102,241,.35);
    background:rgba(99,102,241,.07);font-size:12px;line-height:1.45
  }
  #ms-studio-master-modal .studio-frame-source-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}
  #ms-studio-master-modal .studio-frame-source-actions button {
    padding:11px 8px;min-height:44px;border-radius:10px;
    background:#315cdd;color:white;font-weight:700
  }
}
@media (max-width:768px) {
  #ms-studio-master-modal .studio-identity-bar {
    display:grid !important;
    grid-template-columns:minmax(0,1fr) auto !important;
    align-items:center !important;
    flex-wrap:nowrap !important;
    gap:6px !important;
    min-height:58px !important;
    padding:7px 8px !important;
  }
  #ms-studio-master-modal .studio-identity-main {
    order:initial !important; min-width:0 !important; width:auto !important;
    display:flex !important; gap:6px !important; overflow:hidden;
  }
  #ms-studio-master-modal .studio-identity-main #studio-design-name { display:none !important; }
  #ms-studio-master-modal #studio-save-status {
    width:10px !important; min-width:10px !important; height:10px !important;
    padding:0 !important; overflow:hidden !important; color:transparent !important;
    border:1px solid rgba(255,255,255,.75) !important; border-radius:999px !important;
  }
  #ms-studio-master-modal .studio-menubar { display:none !important; }
  #ms-studio-master-modal .studio-primary-actions {
    order:initial !important; width:auto !important; max-width:none !important; margin:0 !important;
    display:flex !important; align-items:center !important; gap:5px !important; overflow:visible !important;
  }
  #ms-studio-master-modal #studio-preview-btn { display:none !important; }
  #ms-studio-master-modal .studio-mobile-menu-trigger { display:inline-flex !important; align-items:center; justify-content:center; }
  #ms-studio-master-modal .studio-primary-actions > button {
    min-width:0 !important; min-height:42px !important; height:42px !important;
    padding:7px 10px !important; border-radius:12px !important; font-size:11px !important;
  }
  #ms-studio-master-modal .studio-history-actions { display:inline-flex !important; align-items:center; gap:4px; flex:0 0 auto; }
  #ms-studio-master-modal .studio-history-button {
    width:40px !important; min-width:40px !important; height:40px !important; min-height:40px !important;
    padding:0 !important; border-radius:12px !important;
  }
  #ms-studio-master-modal .studio-publish-button { padding-inline:12px !important; }
  #ms-studio-master-modal .studio-back-short { font-size:11px; }
  #ms-studio-master-modal .studio-identity-main > button { min-height:42px !important; padding:7px 9px !important; }

  /* The tool drawer is the mobile work surface. Give it the phone width instead
     of leaving a useless grey strip beside a cramped 330px desktop panel. */
  #ms-studio-master-modal #studio-tool-panel {
    /* Leave a real tap target for the scrim. A 100%-wide drawer made the
       close backdrop unreachable on phones. */
    width:calc(100% - 46px) !important;
    max-width:380px !important;
    right:auto !important;
    border-right:1px solid #dbe3ef !important;
    box-shadow:14px 0 34px rgba(15,23,42,.22) !important;
    border-radius:0 18px 18px 0 !important;
  }
  #ms-studio-master-modal .studio-tool-panel-header {
    position:sticky !important;
    top:0 !important;
    z-index:8 !important;
    min-height:54px !important;
    flex:none !important;
    backdrop-filter:blur(16px);
  }
  #ms-studio-master-modal .studio-tool-panel-close {
    min-width:82px !important;
    min-height:38px !important;
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    gap:5px !important;
    border:1px solid #cbd5e1 !important;
    background:#fff !important;
    color:#0f172a !important;
  }
  #ms-studio-master-modal .studio-tool-panel-close-desktop { display:none !important; }
  #ms-studio-master-modal .studio-tool-panel-close-mobile { display:inline !important; font-size:11px !important; font-weight:900 !important; }
  #ms-studio-master-modal #studio-tool-panel-content {
    min-height:0 !important;
    overflow-y:auto !important;
    -webkit-overflow-scrolling:touch !important;
    overscroll-behavior:contain !important;
  }
  #ms-studio-master-modal #studio-inspector-panel {
    max-height:68dvh !important; border-radius:18px 18px 0 0 !important;
  }

  /* Curated content must remain readable regardless of whichever late-injected
     element stylesheet wins source order. */
  #ms-studio-master-modal .ms-curated-grid {
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
    gap:10px !important;
  }
  #ms-studio-master-modal .ms-curated-element-card { min-height:156px; border-radius:14px !important; }
  #ms-studio-master-modal .ms-curated-element-main { padding:9px !important; }
  #ms-studio-master-modal .ms-curated-element-card .studio-visual-element-preview { min-height:96px !important; }
  #ms-studio-master-modal .ms-curated-premade-preview { min-height:92px !important; padding:10px !important; }
  #ms-studio-master-modal .ms-curated-favorite {
    width:34px !important; height:34px !important; min-height:34px !important;
    padding:0 !important; border-radius:10px !important; font-size:16px !important;
  }
  #ms-studio-master-modal .studio-catalog-card-copy b { font-size:11px !important; line-height:1.2 !important; }
  #ms-studio-master-modal .studio-catalog-card-copy span { font-size:9px !important; line-height:1.25 !important; }

  #ms-studio-master-modal #studio-action-sheet {
    align-items:flex-end !important; justify-content:center !important;
    padding:0 !important; background:rgba(15,23,42,.56) !important;
  }
  #ms-studio-master-modal #studio-action-sheet > section {
    max-width:none !important; width:100% !important; max-height:88dvh !important;
    border-radius:24px 24px 0 0 !important; border-bottom:0 !important;
  }
  #ms-studio-master-modal #studio-action-sheet > section > header { padding:14px 16px !important; }
  #ms-studio-master-modal #studio-action-sheet > section > header h2 { font-size:18px !important; }
  #ms-studio-master-modal #studio-action-sheet > section > div { padding:16px !important; }
}


/* openStudioSheet() mounts on document.body, outside #ms-studio-master-modal.
   These direct selectors are required for the phone bottom-sheet treatment. */
@media (max-width:768px) {
  #studio-action-sheet {
    align-items:flex-end !important;
    justify-content:center !important;
    padding:0 !important;
    background:rgba(15,23,42,.56) !important;
  }
  #studio-action-sheet > section {
    width:100% !important;
    max-width:none !important;
    max-height:88dvh !important;
    border-radius:24px 24px 0 0 !important;
    border-bottom:0 !important;
    padding-bottom:max(12px,env(safe-area-inset-bottom)) !important;
  }
  #studio-action-sheet > section > header { padding:14px 16px !important; }
  #studio-action-sheet > section > header h2 { font-size:18px !important; line-height:1.2 !important; }
  #studio-action-sheet > section > div { padding:16px !important; }
  #studio-action-sheet .studio-mobile-menu-shell { display:grid; gap:20px; }
  #studio-action-sheet .studio-mobile-menu-section { display:grid; gap:9px; }
  #studio-action-sheet .studio-mobile-menu-heading { display:flex;align-items:flex-end;justify-content:space-between;gap:10px; }
  #studio-action-sheet .studio-mobile-menu-heading b { font-size:13px;font-weight:900;color:#0f172a; }
  #studio-action-sheet .studio-mobile-menu-heading span { font-size:10px;color:#64748b;text-align:right; }
  #studio-action-sheet .studio-mobile-menu-grid { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px; }
  #studio-action-sheet .studio-mobile-menu-item {
    display:flex;flex-direction:column;align-items:flex-start;justify-content:center;min-height:70px;
    padding:11px 12px;border:1px solid #dbe3ef;border-radius:14px;background:#f8fafc;
    color:#0f172a;text-align:left;
  }
  #studio-action-sheet .studio-mobile-menu-item b { font-size:12px;line-height:1.15;font-weight:900; }
  #studio-action-sheet .studio-mobile-menu-item span { margin-top:4px;color:#64748b;font-size:9.5px;line-height:1.3;font-weight:650; }
  html.dark #studio-action-sheet .studio-mobile-menu-heading b { color:#f8fafc; }
  html.dark #studio-action-sheet .studio-mobile-menu-heading span,
  html.dark #studio-action-sheet .studio-mobile-menu-item span { color:#9aabc1; }
  html.dark #studio-action-sheet .studio-mobile-menu-item { background:#111d32;border-color:#344866;color:#f8fafc; }
}


@media (max-width:768px) {
  html.dark #ms-studio-master-modal .studio-tool-panel-header { background:rgba(13,23,41,.96) !important; }
  html.dark #ms-studio-master-modal .studio-tool-panel-close {
    background:#182740 !important;
    color:#f8fafc !important;
    border-color:#415574 !important;
  }
}


/* ── Design Studio preview-first UI · 2026-10-06 ─────────────────────── */
#ms-studio-master-modal .ms-curated-element-card {
  overflow:hidden;
  border:1px solid #e2e8f0;
  background:#fff;
  box-shadow:0 1px 2px rgba(15,23,42,.04);
  transition:border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
#ms-studio-master-modal .ms-curated-element-card:hover {
  border-color:#a5b4fc;
  box-shadow:0 10px 24px rgba(15,23,42,.10);
  transform:translateY(-1px);
}
#ms-studio-master-modal .studio-visual-element-preview {
  min-height:112px;
  border-radius:12px;
  overflow:hidden;
  background:linear-gradient(145deg,#f8fafc,#eef2ff);
  border:1px solid rgba(203,213,225,.7);
}
#ms-studio-master-modal .ms-curated-illustration-svg {
  width:100%;
  height:100%;
  min-height:108px;
  display:block;
  padding:8px;
}
#ms-studio-master-modal .ms-auto-pack-visual {
  position:relative;
  min-height:112px;
  width:100%;
  overflow:hidden;
  border-radius:11px;
  background:
    radial-gradient(circle at 80% 15%,color-mix(in srgb,var(--pack-accent) 28%,transparent),transparent 34%),
    linear-gradient(145deg,#0f172a,#1e293b);
  color:#fff;
}
#ms-studio-master-modal .ms-auto-pack-badge {
  position:absolute;left:8px;top:8px;z-index:3;
  max-width:68%;padding:4px 6px;border-radius:6px;
  background:var(--pack-accent);color:#fff;
  font:900 8px/1 ui-sans-serif,sans-serif;letter-spacing:.06em;
}
#ms-studio-master-modal .ms-auto-pack-vehicle {
  position:absolute;left:10px;right:10px;top:34px;height:42px;
}
#ms-studio-master-modal .ms-auto-pack-vehicle .body {
  position:absolute;left:10%;right:7%;bottom:6px;height:20px;border-radius:11px 15px 7px 7px;background:#f8fafc;
}
#ms-studio-master-modal .ms-auto-pack-vehicle .roof {
  position:absolute;left:29%;width:38%;bottom:21px;height:17px;border-radius:18px 18px 3px 3px;background:#e2e8f0;
}
#ms-studio-master-modal .ms-auto-pack-vehicle .wheel {
  position:absolute;bottom:0;width:13px;height:13px;border-radius:50%;background:#020617;border:3px solid #94a3b8;
}
#ms-studio-master-modal .ms-auto-pack-vehicle .wheel.a { left:23%; }
#ms-studio-master-modal .ms-auto-pack-vehicle .wheel.b { right:18%; }
#ms-studio-master-modal .ms-auto-pack-offer {
  position:absolute;left:9px;bottom:27px;
  font:950 14px/1 ui-sans-serif,sans-serif;letter-spacing:-.04em;
}
#ms-studio-master-modal .ms-auto-pack-lines {
  position:absolute;right:8px;bottom:31px;width:34%;display:grid;gap:4px;
}
#ms-studio-master-modal .ms-auto-pack-lines i { height:4px;border-radius:999px;background:rgba(255,255,255,.62); }
#ms-studio-master-modal .ms-auto-pack-lines i:last-child { width:68%; }
#ms-studio-master-modal .ms-auto-pack-cta {
  position:absolute;left:8px;bottom:7px;
  padding:4px 7px;border-radius:6px;background:#fff;color:#0f172a;
  font:900 7px/1 ui-sans-serif,sans-serif;letter-spacing:.04em;
}

/* V39 template discovery.
   One control surface powers both Design Studio and Marketing > Templates. */
.studio-template-discovery {
  display:grid;
  gap:10px;
  padding:12px;
  border:1px solid #e2e8f0;
  border-radius:16px;
  background:rgba(248,250,252,.82);
}
.studio-template-discovery-top {
  display:grid;
  grid-template-columns:minmax(220px,1fr) auto auto;
  gap:9px;
  align-items:center;
}
.studio-template-discovery-search {
  display:flex;
  min-width:0;
  min-height:42px;
  align-items:center;
  gap:9px;
  padding:0 12px;
  border:1px solid #cbd5e1;
  border-radius:12px;
  background:#fff;
  box-shadow:0 1px 2px rgba(15,23,42,.04);
}
.studio-template-discovery-search:focus-within {
  border-color:#60a5fa;
  box-shadow:0 0 0 3px rgba(59,130,246,.12);
}
.studio-template-discovery-search svg {
  width:17px;
  height:17px;
  flex:none;
  fill:none;
  stroke:#64748b;
  stroke-width:2;
}
.studio-template-discovery-search input {
  width:100%;
  min-width:0;
  border:0;
  outline:0;
  background:transparent;
  color:#0f172a;
  font:700 12px/1.2 ui-sans-serif,sans-serif;
}
.studio-template-discovery-search input::placeholder { color:#94a3b8; }
.studio-template-discovery-sort {
  display:flex;
  min-height:42px;
  align-items:center;
  gap:8px;
  padding:0 10px 0 12px;
  border:1px solid #cbd5e1;
  border-radius:12px;
  background:#fff;
  color:#64748b;
  font:800 10px/1 ui-sans-serif,sans-serif;
}
.studio-template-discovery-sort select {
  border:0;
  outline:0;
  background:transparent;
  color:#0f172a;
  font:900 11px/1 ui-sans-serif,sans-serif;
  cursor:pointer;
}
.studio-template-discovery-clear {
  min-height:42px;
  padding:0 13px;
  border:1px solid #cbd5e1;
  border-radius:12px;
  background:#fff;
  color:#334155;
  font:900 10.5px/1 ui-sans-serif,sans-serif;
  cursor:pointer;
}
.studio-template-discovery-clear:hover { border-color:#93c5fd;color:#1d4ed8; }
.studio-template-discovery-row {
  display:flex;
  min-width:0;
  align-items:center;
  gap:7px;
  overflow-x:auto;
  padding-bottom:1px;
  scrollbar-width:none;
}
.studio-template-discovery-row::-webkit-scrollbar { display:none; }
.studio-template-discovery-label {
  position:sticky;
  left:0;
  z-index:1;
  flex:none;
  min-width:42px;
  padding-right:5px;
  background:linear-gradient(90deg,rgba(248,250,252,.98) 80%,rgba(248,250,252,0));
  color:#64748b;
  font:900 9px/1 ui-sans-serif,sans-serif;
  letter-spacing:.08em;
  text-transform:uppercase;
}
.studio-discovery-chip {
  flex:none;
  min-height:32px;
  padding:0 11px;
  border:1px solid #cbd5e1;
  border-radius:999px;
  background:#fff;
  color:#475569;
  font:850 10px/1 ui-sans-serif,sans-serif;
  white-space:nowrap;
  cursor:pointer;
  transition:border-color .14s ease,background .14s ease,color .14s ease,box-shadow .14s ease;
}
.studio-discovery-chip:hover { border-color:#93c5fd;color:#1d4ed8; }
.studio-discovery-chip[aria-pressed="true"] {
  border-color:#2563eb;
  background:#eff6ff;
  color:#1d4ed8;
  box-shadow:inset 0 0 0 1px rgba(37,99,235,.06);
}
.studio-discovery-chip--quick {
  border-color:#bfdbfe;
  background:#f8fbff;
  color:#1e40af;
}
.studio-template-discovery-divider {
  width:1px;
  height:22px;
  flex:none;
  margin:0 2px;
  background:#dbe4ef;
}
.dark .studio-template-discovery {
  border-color:#293a55;
  background:rgba(15,23,42,.66);
}
.dark .studio-template-discovery-search,
.dark .studio-template-discovery-sort,
.dark .studio-template-discovery-clear,
.dark .studio-discovery-chip {
  border-color:#334155;
  background:#111d32;
  color:#dbeafe;
}
.dark .studio-template-discovery-search input,
.dark .studio-template-discovery-sort select { color:#eef4ff; }
.dark .studio-template-discovery-label {
  background:linear-gradient(90deg,rgba(15,23,42,.98) 80%,rgba(15,23,42,0));
  color:#94a3b8;
}
.dark .studio-discovery-chip[aria-pressed="true"] {
  border-color:#60a5fa;
  background:rgba(37,99,235,.18);
  color:#bfdbfe;
}
.dark .studio-discovery-chip--quick {
  border-color:#315b91;
  background:#10213d;
  color:#bfdbfe;
}
.dark .studio-template-discovery-divider { background:#334155; }

@media (max-width:700px) {
  .studio-template-discovery { padding:10px; }
  .studio-template-discovery-top { grid-template-columns:minmax(0,1fr) auto; }
  .studio-template-discovery-sort { grid-column:1/2;grid-row:2;justify-content:space-between; }
  .studio-template-discovery-clear { grid-column:2;grid-row:2; }
}

/* V40 library memory + campaign shelves. */
.studio-discovery-count {
  display:inline-flex;
  min-width:18px;
  height:18px;
  align-items:center;
  justify-content:center;
  margin-left:4px;
  padding:0 5px;
  border-radius:999px;
  background:#e2e8f0;
  color:#475569;
  font:900 8px/1 ui-sans-serif,sans-serif;
}
.studio-discovery-chip[aria-pressed="true"] .studio-discovery-count {
  background:#dbeafe;
  color:#1d4ed8;
}
.studio-template-favorite-button {
  display:inline-flex;
  width:42px;
  height:42px;
  flex:none;
  align-items:center;
  justify-content:center;
  border:1px solid #cbd5e1;
  border-radius:12px;
  background:#fff;
  color:#64748b;
  cursor:pointer;
  transition:transform .14s ease,border-color .14s ease,color .14s ease,background .14s ease,box-shadow .14s ease;
}
.studio-template-favorite-button svg { width:19px;height:19px; }
.studio-template-favorite-button:hover {
  transform:translateY(-1px);
  border-color:#93c5fd;
  color:#2563eb;
  box-shadow:0 7px 16px rgba(15,23,42,.10);
}
.studio-template-favorite-button.is-favorite,
.studio-template-favorite-button[aria-pressed="true"] {
  border-color:#f6c453;
  background:#fffbeb;
  color:#d97706;
}
#studio-home-template-grid .studio-template-favorite-card {
  position:absolute;
  right:9px;
  top:9px;
  z-index:4;
  width:32px;
  height:32px;
  border-color:rgba(255,255,255,.72);
  border-radius:9px;
  background:rgba(255,255,255,.90);
  box-shadow:0 5px 14px rgba(15,23,42,.14);
  backdrop-filter:blur(10px);
}
#studio-home-template-grid .studio-template-favorite-card svg { width:15px;height:15px; }
.dark .studio-discovery-count { background:#26364e;color:#cbd5e1; }
.dark .studio-discovery-chip[aria-pressed="true"] .studio-discovery-count { background:#1e3a5f;color:#bfdbfe; }
.dark .studio-template-favorite-button { border-color:#334155;background:#111d32;color:#94a3b8; }
.dark .studio-template-favorite-button.is-favorite,
.dark .studio-template-favorite-button[aria-pressed="true"] {
  border-color:#a16207;
  background:#332509;
  color:#fbbf24;
}
.dark #studio-home-template-grid .studio-template-favorite-card {
  border-color:rgba(71,85,105,.84);
  background:rgba(15,23,42,.88);
}
@media (max-width:640px) {
  #studio-home-template-grid .studio-template-favorite-card {
    width:30px;height:30px;right:7px;top:7px;
  }
}

/* Shared template storefront cards.
   These rules intentionally target the grid id instead of the Studio modal so
   the exact same polished cards render on Marketing > Templates as well. */
#studio-home-template-grid {
  grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  gap:14px !important;
  align-items:stretch !important;
}
#studio-home-template-grid .studio-home-template-card {
  display:flex;
  min-width:0;
  height:100%;
  flex-direction:column;
  overflow:hidden;
  border:1px solid #e2e8f0;
  border-radius:16px;
  background:#fff;
  box-shadow:0 2px 8px rgba(15,23,42,.06);
  transition:border-color .16s ease,box-shadow .16s ease,transform .16s ease;
}
#studio-home-template-grid .studio-home-template-card:hover {
  border-color:#93c5fd;
  box-shadow:0 14px 30px rgba(15,23,42,.12);
  transform:translateY(-2px);
}
#studio-home-template-grid .studio-template-visual {
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  aspect-ratio:4/3;
  min-height:0;
  padding:12px;
  overflow:hidden;
  background:#eef2f7;
}
#studio-home-template-grid .studio-template-preview-fit {
  position:relative;
  display:block;
  max-width:100%;
  max-height:100%;
  overflow:hidden;
  border-radius:8px;
  box-shadow:0 8px 22px rgba(15,23,42,.18);
  aspect-ratio:var(--studio-template-ratio);
}
#studio-home-template-grid .studio-template-preview-fit.fit-width { width:100%; }
#studio-home-template-grid .studio-template-preview-fit.fit-height { height:100%; }
#studio-home-template-grid .studio-template-preview-fit > .studio-template-preview {
  width:100% !important;
  height:100% !important;
  max-width:none !important;
  max-height:none !important;
  border-radius:0 !important;
  box-shadow:none !important;
}
#studio-home-template-grid .studio-template-meta {
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:12px;
  min-height:88px;
  margin-top:auto;
  padding:12px 13px 13px;
  border-top:1px solid #eef2f7;
}
#studio-home-template-grid .studio-template-meta-copy {
  display:block;
  min-width:0;
  padding:0;
  border:0;
  background:transparent;
}
#studio-home-template-grid .studio-template-meta-copy b {
  display:-webkit-box;
  min-height:2.5em;
  overflow:hidden;
  color:#0f172a;
  font:900 13.5px/1.25 ui-sans-serif,sans-serif;
  letter-spacing:-.015em;
  -webkit-box-orient:vertical;
  -webkit-line-clamp:2;
}
#studio-home-template-grid .studio-template-meta-copy span {
  display:block;
  margin-top:5px;
  overflow:hidden;
  color:#64748b;
  font:700 10.5px/1.25 ui-sans-serif,sans-serif;
  text-overflow:ellipsis;
  white-space:nowrap;
}
#studio-home-template-grid .studio-template-use {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:none;
  min-width:86px;
  min-height:40px;
  padding:0 14px;
  border:0;
  border-radius:10px;
  background:#2563eb;
  color:#fff;
  font:900 10.5px/1 ui-sans-serif,sans-serif;
  cursor:pointer;
  box-shadow:0 6px 14px rgba(37,99,235,.18);
}
#studio-home-template-grid .studio-template-use:hover { background:#1d4ed8; }
#studio-home-template-grid .studio-template-preview-button {
  position:absolute;
  inset:0;
  z-index:2;
  border:0;
  background:transparent;
  cursor:pointer;
}
#studio-home-template-grid .studio-template-hover-preview {
  position:absolute;
  left:50%;
  top:50%;
  z-index:3;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:34px;
  padding:0 14px;
  border:1px solid rgba(255,255,255,.68);
  border-radius:999px;
  background:rgba(15,23,42,.82);
  color:#fff;
  font:900 10px/1 ui-sans-serif,sans-serif;
  box-shadow:0 8px 22px rgba(15,23,42,.22);
  opacity:0;
  pointer-events:none;
  transform:translate(-50%,-44%);
  transition:opacity .16s ease,transform .16s ease;
  backdrop-filter:blur(10px);
}
@media (hover:hover) and (pointer:fine) {
  #studio-home-template-grid .studio-home-template-card:hover .studio-template-hover-preview {
    opacity:1;
    transform:translate(-50%,-50%);
  }
}
#studio-home-template-grid .studio-template-card-badge {
  position:absolute;
  left:9px;
  top:9px;
  z-index:3;
  padding:4px 6px;
  border-radius:7px;
  background:rgba(15,23,42,.84);
  color:#fff;
  font:900 8px/1 ui-sans-serif,sans-serif;
  backdrop-filter:blur(8px);
}
.dark #studio-home-template-grid .studio-home-template-card {
  background:#111d32;
  border-color:#2d405f;
}
.dark #studio-home-template-grid .studio-template-visual { background:#0b1527; }
.dark #studio-home-template-grid .studio-template-meta { border-top-color:#223451; }
.dark #studio-home-template-grid .studio-template-meta-copy b { color:#eef4ff; }
.dark #studio-home-template-grid .studio-template-meta-copy span { color:#93a4ba; }

@media (min-width:700px) {
  #studio-home-template-grid { grid-template-columns:repeat(3,minmax(0,1fr)) !important; }
}
@media (min-width:1180px) {
  #studio-home-template-grid { grid-template-columns:repeat(4,minmax(0,1fr)) !important; }
}
@media (max-width:640px) {
  #studio-home-template-grid { gap:10px !important; }
  #studio-home-template-grid .studio-template-visual { padding:8px; }
  #studio-home-template-grid .studio-template-meta { min-height:78px;padding:9px;gap:7px; }
  #studio-home-template-grid .studio-template-meta-copy b { font-size:11.5px; }
  #studio-home-template-grid .studio-template-meta-copy span { font-size:9.5px; }
  #studio-home-template-grid .studio-template-use { min-width:52px;min-height:36px;padding-inline:10px;font-size:0; }
  #studio-home-template-grid .studio-template-use::after { content:'Use';font:900 10px/1 ui-sans-serif,sans-serif; }
}

/* Templates should be judged visually first. Four useful cards beat six tiny cards. */
#ms-studio-master-modal #studio-home-template-grid {
  grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  gap:14px !important;
}
#ms-studio-master-modal .studio-home-template-card,
#ms-studio-master-modal .studio-template-card {
  border-radius:16px !important;
  background:#fff;
  border:1px solid #e2e8f0;
  box-shadow:0 2px 8px rgba(15,23,42,.06);
}
#ms-studio-master-modal .studio-template-visual {
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:190px;
  padding:12px;
  overflow:hidden;
  background:#eef2f7;
}
#ms-studio-master-modal .studio-template-visual .studio-template-preview {
  width:100%;
  max-height:300px;
  box-shadow:0 8px 22px rgba(15,23,42,.18);
}
#ms-studio-master-modal .studio-template-meta {
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  padding:10px 11px 11px;
}
#ms-studio-master-modal .studio-template-meta-copy { min-width:0; }
#ms-studio-master-modal .studio-template-meta-copy b {
  display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  color:#0f172a;font:900 12px/1.2 ui-sans-serif,sans-serif;
}
#ms-studio-master-modal .studio-template-meta-copy span {
  display:block;margin-top:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  color:#64748b;font:700 9px/1.2 ui-sans-serif,sans-serif;
}
#ms-studio-master-modal .studio-template-use {
  flex:none;min-height:34px;padding:0 10px;border:0;border-radius:9px;
  background:#4f46e5;color:#fff;font:900 10px/1 ui-sans-serif,sans-serif;
}
#ms-studio-master-modal .studio-template-preview-button {
  position:absolute;inset:0;z-index:2;border:0;background:transparent;cursor:pointer;
}
#ms-studio-master-modal .studio-template-card-badge {
  position:absolute;left:9px;top:9px;z-index:3;padding:4px 6px;border-radius:7px;
  background:rgba(15,23,42,.84);color:#fff;font:900 8px/1 ui-sans-serif,sans-serif;
  backdrop-filter:blur(8px);
}
#ms-studio-master-modal .studio-template-preview-sheet {
  display:grid;gap:16px;
}
#ms-studio-master-modal .studio-template-preview-stage {
  display:flex;align-items:center;justify-content:center;
  min-height:360px;padding:18px;border-radius:18px;
  background:#e9eef5;overflow:hidden;
}
#ms-studio-master-modal .studio-template-preview-stage .studio-template-preview {
  max-width:100%;max-height:62dvh;box-shadow:0 18px 45px rgba(15,23,42,.22);
}
#ms-studio-master-modal .studio-template-preview-primary {
  display:grid;grid-template-columns:1fr auto;align-items:center;gap:10px;
}
#ms-studio-master-modal .studio-template-preview-more {
  border:1px solid #dbe3ef;border-radius:12px;padding:10px 12px;
}
#ms-studio-master-modal .studio-template-preview-more summary {
  cursor:pointer;font-size:11px;font-weight:900;color:#334155;
}

@media (min-width:700px) {
  #ms-studio-master-modal #studio-home-template-grid {
    grid-template-columns:repeat(3,minmax(0,1fr)) !important;
  }
}
@media (min-width:1180px) {
  #ms-studio-master-modal #studio-home-template-grid {
    grid-template-columns:repeat(4,minmax(0,1fr)) !important;
  }
}
@media (max-width:640px) {
  #ms-studio-master-modal #studio-home-template-grid { gap:10px !important; }
  #ms-studio-master-modal .studio-template-visual { min-height:148px;padding:8px; }
  #ms-studio-master-modal .studio-template-meta { padding:8px; }
  #ms-studio-master-modal .studio-template-meta-copy b { font-size:11px; }
  #ms-studio-master-modal .studio-template-use { min-height:36px;padding-inline:9px; }
  #ms-studio-master-modal .studio-template-preview-stage { min-height:260px;padding:10px; }
  #ms-studio-master-modal .studio-template-preview-primary {
    grid-template-columns:1fr;
  }
}
.dark #ms-studio-master-modal .ms-curated-element-card,
.dark #ms-studio-master-modal .studio-home-template-card,
.dark #ms-studio-master-modal .studio-template-card { background:#111d32;border-color:#2d405f; }
.dark #ms-studio-master-modal .studio-visual-element-preview,
.dark #ms-studio-master-modal .studio-template-visual,
.dark #ms-studio-master-modal .studio-template-preview-stage { background:#0b1527; }
.dark #ms-studio-master-modal .studio-template-meta-copy b { color:#eef4ff; }
.dark #ms-studio-master-modal .studio-template-meta-copy span { color:#93a4ba; }
.dark #ms-studio-master-modal .studio-template-preview-more { border-color:#344866; }
.dark #ms-studio-master-modal .studio-template-preview-more summary { color:#dbeafe; }


/* ── Design Studio browser simplification · 2026-10-06 ─────────────── */
#ms-studio-master-modal .studio-template-browser { display:grid; gap:12px; }
#ms-studio-master-modal .studio-template-browser-head {
  display:flex;align-items:flex-start;justify-content:space-between;gap:10px;
}
#ms-studio-master-modal .studio-template-browser-head h3 {
  margin:0;color:#0f172a;font:900 14px/1.2 ui-sans-serif,sans-serif;
}
#ms-studio-master-modal .studio-template-browser-head p {
  margin:4px 0 0;color:#64748b;font:600 9.5px/1.4 ui-sans-serif,sans-serif;
}
#ms-studio-master-modal .studio-template-size-chip {
  flex:none;display:flex;flex-direction:column;align-items:flex-end;gap:2px;
  min-height:42px;padding:7px 9px;border:1px solid #c7d2fe;border-radius:11px;
  background:#eef2ff;color:#3730a3;text-align:right;
}
#ms-studio-master-modal .studio-template-size-chip b { font-size:10px;line-height:1; }
#ms-studio-master-modal .studio-template-size-chip span { font-size:8px;font-weight:700;opacity:.76; }
#ms-studio-master-modal .studio-template-search {
  display:flex;align-items:center;gap:7px;min-height:42px;padding:0 11px;
  border:1px solid #cbd5e1;border-radius:12px;background:#f8fafc;color:#64748b;
}
#ms-studio-master-modal .studio-template-search input {
  min-width:0;flex:1;border:0!important;outline:0;background:transparent!important;
  padding:0!important;color:#0f172a;font-size:12px;
}
#ms-studio-master-modal .studio-template-category-select {
  width:100%;min-height:40px;padding:0 10px;border:1px solid #cbd5e1;border-radius:11px;
  background:#fff;color:#334155;font-size:11px;font-weight:800;
}
#ms-studio-master-modal .studio-template-filter-row {
  display:flex;align-items:center;gap:8px;min-width:0;
}
#ms-studio-master-modal .studio-template-category-chips {
  display:flex;gap:6px;min-width:0;overflow-x:auto;padding:1px 1px 4px;
  scroll-snap-type:x proximity;scrollbar-width:none;
}
#ms-studio-master-modal .studio-template-category-chips::-webkit-scrollbar { display:none; }
#ms-studio-master-modal .studio-template-category-chip {
  flex:none;display:inline-flex;align-items:center;gap:5px;min-height:34px;padding:0 9px;
  border:1px solid #dbe3ef;border-radius:999px;background:#fff;color:#475569;
  font:800 9.5px/1 ui-sans-serif,sans-serif;white-space:nowrap;scroll-snap-align:start;
}
#ms-studio-master-modal .studio-template-category-chip em {
  min-width:17px;padding:3px 5px;border-radius:999px;background:#f1f5f9;color:#64748b;
  font:900 8px/1 ui-sans-serif,sans-serif;font-style:normal;text-align:center;
}
#ms-studio-master-modal .studio-template-category-chip[aria-pressed="true"] {
  border-color:#6366f1;background:#eef2ff;color:#3730a3;box-shadow:0 0 0 2px rgba(99,102,241,.10);
}
#ms-studio-master-modal .studio-template-category-chip[aria-pressed="true"] em {
  background:#c7d2fe;color:#312e81;
}
#ms-studio-master-modal .studio-template-filter-reset {
  flex:none;min-height:34px;padding:0 9px;border:0;border-radius:9px;background:#f1f5f9;
  color:#475569;font:900 9px/1 ui-sans-serif,sans-serif;
}
#ms-studio-master-modal .studio-template-browser-status {
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  padding:8px 9px;border-radius:10px;background:#f8fafc;color:#64748b;
  font:700 8.5px/1.3 ui-sans-serif,sans-serif;
}
#ms-studio-master-modal .studio-template-browser-status b { color:#334155; }
#ms-studio-master-modal .studio-template-browser-grid { display:grid;grid-template-columns:1fr;gap:11px; }
#ms-studio-master-modal .studio-template-browser-grid > .studio-template-card + button {
  grid-column:1/-1;
}
#ms-studio-master-modal .studio-template-tools {
  margin-top:2px;border:1px solid #dbe3ef;border-radius:13px;background:#f8fafc;
}
#ms-studio-master-modal .studio-template-tools summary {
  cursor:pointer;padding:11px 12px;color:#334155;font-size:11px;font-weight:900;
}
#ms-studio-master-modal .studio-template-tools-body { display:grid;gap:8px;padding:0 10px 10px; }
#ms-studio-master-modal .studio-template-tool-row {
  display:flex;flex-direction:column;align-items:flex-start;gap:3px;width:100%;
  padding:10px;border:1px solid #dbe3ef;border-radius:10px;background:#fff;text-align:left;
}
#ms-studio-master-modal .studio-template-tool-row b { color:#0f172a;font-size:10px; }
#ms-studio-master-modal .studio-template-tool-row span { color:#64748b;font-size:9px;line-height:1.35; }
#ms-studio-master-modal .studio-template-ai-box {
  display:grid;gap:7px;padding:10px;border-radius:10px;background:#eef2ff;
}
#ms-studio-master-modal .studio-template-ai-box>b { color:#312e81;font-size:10px; }
#ms-studio-master-modal .studio-template-ai-box>span { color:#4338ca;font-size:9px;line-height:1.35; }
#ms-studio-master-modal .studio-template-ai-box textarea {
  width:100%;resize:vertical;min-height:72px;padding:9px;border:1px solid #c7d2fe;
  border-radius:9px;background:#fff;color:#0f172a;font-size:10px;
}
#ms-studio-master-modal .studio-template-ai-box button {
  min-height:38px;border:0;border-radius:9px;background:#4f46e5;color:#fff;font-size:10px;font-weight:900;
}

@media (max-width:768px) {
  #ms-studio-master-modal .studio-template-browser-grid {
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px;
  }
  #ms-studio-master-modal .studio-template-browser-grid > button:last-child {
    grid-column:1/-1;
  }
  #ms-studio-master-modal .studio-template-browser .studio-template-visual { min-height:142px; }
  #ms-studio-master-modal .studio-template-browser .studio-template-meta {
    align-items:stretch;flex-direction:column;
  }
  #ms-studio-master-modal .studio-template-browser .studio-template-use { width:100%; }
  #ms-studio-master-modal .studio-template-filter-row { align-items:stretch; }
  #ms-studio-master-modal .studio-template-category-chip { min-height:38px;padding-inline:10px; }
  #ms-studio-master-modal .studio-template-filter-reset { min-height:38px; }
  #ms-studio-master-modal .studio-template-browser-status { align-items:flex-start;flex-direction:column; }
}

.dark #ms-studio-master-modal .studio-template-browser-head h3 { color:#eef4ff; }
.dark #ms-studio-master-modal .studio-template-browser-head p { color:#93a4ba; }
.dark #ms-studio-master-modal .studio-template-size-chip {
  border-color:#3f51a3;background:#1e3053;color:#c7d2fe;
}
.dark #ms-studio-master-modal .studio-template-search,
.dark #ms-studio-master-modal .studio-template-category-select,
.dark #ms-studio-master-modal .studio-template-tools {
  border-color:#344866;background:#091426;color:#e7eef8;
}
.dark #ms-studio-master-modal .studio-template-search input { color:#f8fafc; }
.dark #ms-studio-master-modal .studio-template-category-chip {
  border-color:#344866;background:#111d32;color:#cbd5e1;
}
.dark #ms-studio-master-modal .studio-template-category-chip em { background:#1e293b;color:#94a3b8; }
.dark #ms-studio-master-modal .studio-template-category-chip[aria-pressed="true"] {
  border-color:#6366f1;background:#1e3053;color:#e0e7ff;
}
.dark #ms-studio-master-modal .studio-template-filter-reset,
.dark #ms-studio-master-modal .studio-template-browser-status { background:#111d32;color:#93a4ba; }
.dark #ms-studio-master-modal .studio-template-browser-status b { color:#e2e8f0; }
.dark #ms-studio-master-modal .studio-template-tool-row {
  border-color:#344866;background:#111d32;
}
.dark #ms-studio-master-modal .studio-template-tool-row b { color:#eef4ff; }
.dark #ms-studio-master-modal .studio-template-tool-row span { color:#93a4ba; }
.dark #ms-studio-master-modal .studio-template-ai-box { background:#182740; }
.dark #ms-studio-master-modal .studio-template-ai-box>b { color:#dbeafe; }
.dark #ms-studio-master-modal .studio-template-ai-box>span { color:#9fb4d2; }
.dark #ms-studio-master-modal .studio-template-ai-box textarea {
  border-color:#415574;background:#091426;color:#f8fafc;
}


/* ── Design Studio media preview consistency · 2026-10-06 ───────────── */
#ms-studio-master-modal .studio-photo-result-card,
#ms-studio-master-modal .studio-media-preview-card {
  overflow:hidden;
  border:1px solid #e2e8f0;
  border-radius:14px;
  background:#fff;
  box-shadow:0 1px 3px rgba(15,23,42,.05);
  transition:border-color .16s ease,box-shadow .16s ease,transform .16s ease;
}
#ms-studio-master-modal .studio-photo-result-card:hover,
#ms-studio-master-modal .studio-media-preview-card:hover {
  border-color:#a5b4fc;
  box-shadow:0 10px 24px rgba(15,23,42,.10);
  transform:translateY(-1px);
}
#ms-studio-master-modal .studio-photo-result-preview,
#ms-studio-master-modal .studio-media-preview-add {
  position:relative;
  display:block;
  width:100%;
  min-height:128px;
  overflow:hidden;
  border:0;
  padding:0;
  background:linear-gradient(145deg,#e2e8f0,#f8fafc);
  color:inherit;
  text-align:left;
}
#ms-studio-master-modal .studio-photo-result-preview img,
#ms-studio-master-modal .studio-media-preview-add img,
#ms-studio-master-modal .studio-media-preview-add video {
  display:block;
  width:100%;
  aspect-ratio:1/1;
  object-fit:cover;
  transition:transform .18s ease;
}
#ms-studio-master-modal .studio-photo-result-preview:hover img,
#ms-studio-master-modal .studio-media-preview-add:hover img {
  transform:scale(1.025);
}
#ms-studio-master-modal .studio-photo-result-preview.is-broken::before,
#ms-studio-master-modal .studio-media-preview-add.is-broken::before {
  content:'Preview unavailable';
  position:absolute;inset:0;
  display:grid;place-items:center;
  color:#64748b;font:800 10px/1.2 ui-sans-serif,sans-serif;
}
#ms-studio-master-modal .studio-photo-result-add,
#ms-studio-master-modal .studio-media-add-pill {
  position:absolute;right:7px;bottom:7px;z-index:3;
  padding:5px 8px;border-radius:8px;
  background:rgba(15,23,42,.86);color:#fff;
  font:900 9px/1 ui-sans-serif,sans-serif;
  backdrop-filter:blur(8px);
  opacity:0;transform:translateY(2px);
  transition:opacity .16s ease,transform .16s ease;
}
#ms-studio-master-modal .studio-photo-result-preview:hover .studio-photo-result-add,
#ms-studio-master-modal .studio-photo-result-preview:focus-visible .studio-photo-result-add,
#ms-studio-master-modal .studio-media-preview-add:hover .studio-media-add-pill,
#ms-studio-master-modal .studio-media-preview-add:focus-visible .studio-media-add-pill {
  opacity:1;transform:none;
}
#ms-studio-master-modal .studio-photo-result-meta {
  min-width:0;padding:8px 9px;
}
#ms-studio-master-modal .studio-photo-result-meta b {
  display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  color:#0f172a;font:850 9.5px/1.2 ui-sans-serif,sans-serif;
}
#ms-studio-master-modal .studio-photo-result-meta a {
  display:block;margin-top:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  color:#4f46e5;font:750 8.5px/1.2 ui-sans-serif,sans-serif;
}
#ms-studio-master-modal .studio-media-preview { position:relative; }
#ms-studio-master-modal .studio-media-favorite {
  position:absolute;left:7px;top:7px;z-index:5;
  display:grid;place-items:center;width:30px;height:30px;
  border:0;border-radius:9px;background:rgba(255,255,255,.92);
  color:#4338ca;font-size:15px;box-shadow:0 2px 8px rgba(15,23,42,.15);
}
#ms-studio-master-modal .studio-media-type-badge {
  position:absolute;left:7px;bottom:7px;z-index:3;
  padding:4px 6px;border-radius:7px;background:rgba(15,23,42,.82);
  color:#fff;font:900 7px/1 ui-sans-serif,sans-serif;letter-spacing:.07em;
}
#ms-studio-master-modal .studio-media-preview-meta {
  display:grid;grid-template-columns:minmax(0,1fr) 32px;align-items:center;gap:6px;
  padding:8px;
}
#ms-studio-master-modal .studio-media-title {
  min-width:0;border:0;background:none;padding:0;text-align:left;color:inherit;
}
#ms-studio-master-modal .studio-media-title b,
#ms-studio-master-modal .studio-media-title span {
  display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
#ms-studio-master-modal .studio-media-title b {
  color:#0f172a;font:850 10px/1.2 ui-sans-serif,sans-serif;
}
#ms-studio-master-modal .studio-media-title span {
  margin-top:3px;color:#64748b;font:700 8.5px/1.2 ui-sans-serif,sans-serif;
}
#ms-studio-master-modal .studio-media-details {
  width:32px;height:32px;border:1px solid #e2e8f0;border-radius:9px;
  background:#f8fafc;color:#475569;font-size:12px;font-weight:900;
}
@media (max-width:768px) {
  #ms-studio-master-modal .studio-photo-result-add,
  #ms-studio-master-modal .studio-media-add-pill { opacity:1;transform:none; }
  #ms-studio-master-modal .studio-photo-result-preview,
  #ms-studio-master-modal .studio-media-preview-add { min-height:116px; }
}
.dark #ms-studio-master-modal .studio-photo-result-card,
.dark #ms-studio-master-modal .studio-media-preview-card {
  border-color:#2d405f;background:#111d32;
}
.dark #ms-studio-master-modal .studio-photo-result-preview,
.dark #ms-studio-master-modal .studio-media-preview-add {
  background:linear-gradient(145deg,#0b1527,#182740);
}
.dark #ms-studio-master-modal .studio-photo-result-meta b,
.dark #ms-studio-master-modal .studio-media-title b { color:#eef4ff; }
.dark #ms-studio-master-modal .studio-media-title span { color:#93a4ba; }
.dark #ms-studio-master-modal .studio-media-favorite {
  background:rgba(17,29,50,.94);color:#c7d2fe;
}
.dark #ms-studio-master-modal .studio-media-details {
  border-color:#344866;background:#182740;color:#dbeafe;
}


/* ── Design Studio preview consistency · 2026-10-06 ───────────────────
   Templates and saved projects keep their actual aspect ratio in every browser,
   drawer and preview sheet. openStudioSheet() is body-mounted, so the sheet
   selectors are intentionally not scoped to #ms-studio-master-modal. */
#ms-studio-master-modal .studio-template-preview-fit,
#studio-action-sheet .studio-template-preview-fit {
  position:relative;
  display:block;
  max-width:100%;
  max-height:100%;
  overflow:hidden;
  border-radius:8px;
  background:#fff;
  aspect-ratio:var(--studio-template-ratio);
  box-shadow:0 8px 22px rgba(15,23,42,.18);
}
#ms-studio-master-modal .studio-template-preview-fit.fit-width,
#studio-action-sheet .studio-template-preview-fit.fit-width { width:100%; }
#ms-studio-master-modal .studio-template-preview-fit.fit-height,
#studio-action-sheet .studio-template-preview-fit.fit-height { height:100%; }
#ms-studio-master-modal .studio-template-preview-fit > .studio-template-preview,
#studio-action-sheet .studio-template-preview-fit > .studio-template-preview {
  width:100% !important;
  height:100% !important;
  max-width:none !important;
  max-height:none !important;
  border-radius:0 !important;
  box-shadow:none !important;
}

#ms-studio-master-modal .studio-template-card .studio-template-visual {
  width:100%;
  min-height:0 !important;
  aspect-ratio:4/3;
  padding:10px;
}

#ms-studio-master-modal .studio-project-preview-stage,
#studio-action-sheet .studio-project-preview-stage {
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  aspect-ratio:4/3;
  padding:10px;
  overflow:hidden;
  background:#eef2f7;
}
#ms-studio-master-modal .studio-project-preview-fit,
#studio-action-sheet .studio-project-preview-fit {
  position:relative;
  display:block;
  max-width:100%;
  max-height:100%;
  overflow:hidden;
  border-radius:8px;
  background:#fff;
  aspect-ratio:var(--studio-project-ratio);
  box-shadow:0 7px 18px rgba(15,23,42,.16);
}
#ms-studio-master-modal .studio-project-preview-fit.fit-width,
#studio-action-sheet .studio-project-preview-fit.fit-width { width:100%; }
#ms-studio-master-modal .studio-project-preview-fit.fit-height,
#studio-action-sheet .studio-project-preview-fit.fit-height { height:100%; }
#ms-studio-master-modal .studio-project-preview-fit > .studio-template-preview,
#studio-action-sheet .studio-project-preview-fit > .studio-template-preview {
  width:100% !important;
  height:100% !important;
  max-width:none !important;
  max-height:none !important;
  border-radius:0 !important;
  box-shadow:none !important;
}

#studio-action-sheet .studio-template-preview-sheet { display:grid;gap:16px; }
#studio-action-sheet .studio-template-preview-stage {
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  min-height:360px;
  padding:18px;
  border-radius:18px;
  background:#e9eef5;
  overflow:hidden;
}
#studio-action-sheet .studio-template-preview-fit-large.fit-width {
  width:min(100%,920px);
}
#studio-action-sheet .studio-template-preview-fit-large.fit-height {
  height:min(62dvh,720px);
}
#studio-action-sheet .studio-template-preview-primary {
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:12px;
}
#studio-action-sheet .studio-template-preview-more {
  border:1px solid #dbe3ef;
  border-radius:12px;
  padding:10px 12px;
}
#studio-action-sheet .studio-template-preview-more summary {
  cursor:pointer;
  color:#334155;
  font:900 11px/1.2 ui-sans-serif,sans-serif;
}
#studio-action-sheet > section.studio-template-preview-dialog {
  max-width:min(1120px,calc(100vw - 32px)) !important;
}

.dark #ms-studio-master-modal .studio-template-preview-fit,
.dark #ms-studio-master-modal .studio-project-preview-fit,
html.dark #studio-action-sheet .studio-template-preview-fit,
html.dark #studio-action-sheet .studio-project-preview-fit {
  background:#0f172a;
}
.dark #ms-studio-master-modal .studio-project-preview-stage,
html.dark #studio-action-sheet .studio-template-preview-stage,
html.dark #studio-action-sheet .studio-project-preview-stage {
  background:#0b1527;
}
html.dark #studio-action-sheet .studio-template-preview-more { border-color:#344866; }
html.dark #studio-action-sheet .studio-template-preview-more summary { color:#dbeafe; }

@media (max-width:768px) {
  #studio-action-sheet > section.studio-template-preview-dialog { max-width:none !important; }
}
@media (max-width:640px) {
  #ms-studio-master-modal .studio-template-card .studio-template-visual { padding:8px; }
  #ms-studio-master-modal .studio-project-preview-stage,
  #studio-action-sheet .studio-project-preview-stage { padding:8px; }
  #studio-action-sheet .studio-template-preview-stage { min-height:250px;padding:10px; }
  #studio-action-sheet .studio-template-preview-fit-large.fit-height { height:min(50dvh,500px); }
  #studio-action-sheet .studio-template-preview-primary { grid-template-columns:1fr; }
}


/* ── Design Studio preview resilience · 2026-10-06 ─────────────────────
   Never show a dead grey rectangle when the source has no rendered frame yet. */
#ms-studio-master-modal .studio-project-empty-preview,
#studio-action-sheet .studio-project-empty-preview {
  display:grid;
  width:100%;
  height:100%;
  min-height:120px;
  place-content:center;
  justify-items:center;
  gap:6px;
  padding:18px;
  background:
    radial-gradient(circle at 50% 18%,rgba(99,102,241,.16),transparent 34%),
    linear-gradient(145deg,#f8fafc,#eef2ff);
  color:#475569;
  text-align:center;
}
#ms-studio-master-modal .studio-project-empty-icon,
#studio-action-sheet .studio-project-empty-icon {
  display:grid;
  place-items:center;
  width:42px;
  height:42px;
  border:1px solid #c7d2fe;
  border-radius:13px;
  background:#fff;
  color:#4f46e5;
  font:900 22px/1 ui-sans-serif,sans-serif;
  box-shadow:0 6px 18px rgba(79,70,229,.10);
}
#ms-studio-master-modal .studio-project-empty-preview b,
#studio-action-sheet .studio-project-empty-preview b {
  max-width:100%;
  overflow:hidden;
  color:#0f172a;
  font:900 11px/1.2 ui-sans-serif,sans-serif;
  text-overflow:ellipsis;
  white-space:nowrap;
}
#ms-studio-master-modal .studio-project-empty-preview small,
#studio-action-sheet .studio-project-empty-preview small {
  color:#64748b;
  font:750 9px/1 ui-sans-serif,sans-serif;
}

#ms-studio-master-modal .studio-media-preview-add {
  isolation:isolate;
}
#ms-studio-master-modal .studio-media-video-fallback {
  position:absolute;
  inset:0;
  z-index:0;
  display:grid;
  place-content:center;
  justify-items:center;
  gap:7px;
  background:
    radial-gradient(circle at 50% 35%,rgba(99,102,241,.28),transparent 30%),
    linear-gradient(145deg,#0f172a,#1e293b);
  color:#fff;
}
#ms-studio-master-modal .studio-media-video-fallback > span {
  display:grid;
  place-items:center;
  width:42px;
  height:42px;
  padding-left:3px;
  border:1px solid rgba(255,255,255,.28);
  border-radius:50%;
  background:rgba(255,255,255,.14);
  font-size:16px;
  backdrop-filter:blur(8px);
}
#ms-studio-master-modal .studio-media-video-fallback small {
  font:850 9px/1 ui-sans-serif,sans-serif;
  letter-spacing:.04em;
  opacity:.82;
}
#ms-studio-master-modal .studio-media-video {
  position:relative;
  z-index:1;
  opacity:0;
  transition:opacity .18s ease,transform .18s ease;
}
#ms-studio-master-modal .studio-media-preview-add.is-loaded .studio-media-video { opacity:1; }
#ms-studio-master-modal .studio-media-preview-add.is-loaded .studio-media-video-fallback { opacity:0; }
#ms-studio-master-modal .studio-media-preview-add.is-broken .studio-media-video { display:none; }
#ms-studio-master-modal .studio-media-preview-add.is-broken .studio-media-video-fallback small::after {
  content:' unavailable';
}
.dark #ms-studio-master-modal .studio-project-empty-preview,
html.dark #studio-action-sheet .studio-project-empty-preview {
  background:
    radial-gradient(circle at 50% 18%,rgba(99,102,241,.18),transparent 34%),
    linear-gradient(145deg,#0b1527,#111d32);
  color:#cbd5e1;
}
.dark #ms-studio-master-modal .studio-project-empty-icon,
html.dark #studio-action-sheet .studio-project-empty-icon {
  border-color:#344866;
  background:#111d32;
  color:#a5b4fc;
}
.dark #ms-studio-master-modal .studio-project-empty-preview b,
html.dark #studio-action-sheet .studio-project-empty-preview b { color:#f8fafc; }


/* ── Design Studio mobile contextual selection dock · 2026-10-06 ────────
   The old floating object pill was removed on phones because it drifted off
   canvas. This dock keeps the core selected-object actions thumb reachable
   without reopening Menu or forcing the inspector open for every tap. */
#ms-studio-master-modal .studio-mobile-selection-dock { display:none; }

@media (max-width:768px) {
  #ms-studio-master-modal .studio-mobile-selection-dock {
    position:absolute;
    left:12px;
    right:12px;
    bottom:72px;
    z-index:40;
    display:flex;
    align-items:center;
    gap:8px;
    min-height:54px;
    padding:6px 7px;
    border:1px solid rgba(148,163,184,.45);
    border-radius:16px;
    background:rgba(255,255,255,.96);
    box-shadow:0 12px 34px rgba(15,23,42,.18);
    backdrop-filter:blur(18px) saturate(1.2);
  }
  #ms-studio-master-modal .studio-mobile-selection-dock[hidden] { display:none !important; }
  #ms-studio-master-modal .studio-mobile-selection-kind {
    flex:0 0 auto;
    max-width:82px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    padding:0 4px;
    color:#475569;
    font-size:10px;
    font-weight:900;
  }
  #ms-studio-master-modal .studio-mobile-selection-actions {
    display:flex;
    flex:1 1 auto;
    min-width:0;
    gap:6px;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
  }
  #ms-studio-master-modal .studio-mobile-selection-actions::-webkit-scrollbar { display:none; }
  #ms-studio-master-modal .studio-mobile-selection-action {
    flex:0 0 auto;
    min-height:42px;
    padding:0 12px;
    border:1px solid #d7dfeb;
    border-radius:11px;
    background:#f8fafc;
    color:#0f172a;
    font-size:11px;
    font-weight:900;
    white-space:nowrap;
  }
  #ms-studio-master-modal .studio-mobile-selection-action:active {
    transform:translateY(1px);
    background:#eef2ff;
    border-color:#a5b4fc;
  }
  #ms-studio-master-modal .studio-mobile-selection-action.is-danger {
    color:#b91c1c;
    background:#fff7f7;
    border-color:#fecaca;
  }
  html.dark #ms-studio-master-modal .studio-mobile-selection-dock {
    background:rgba(13,23,41,.96);
    border-color:#334155;
    box-shadow:0 12px 34px rgba(2,6,23,.42);
  }
  .dark #ms-studio-master-modal .studio-mobile-selection-kind { color:#aebdd0; }
  html.dark #ms-studio-master-modal .studio-mobile-selection-action {
    background:#111d32;
    border-color:#344866;
    color:#f8fafc;
  }
  html.dark #ms-studio-master-modal .studio-mobile-selection-action.is-danger {
    color:#fecaca;
    background:#3b1820;
    border-color:#7f1d1d;
  }
}


/* Design Studio tablet / Chromebook header: keep actions separate from menus.
   The base theme's later !important wordmark rule could override the intended
   <=1600px compact layout and squeeze the editable design name to zero. */
@media (min-width:769px) and (max-width:1600px) {
  #ms-studio-master-modal .studio-identity-bar {
    display:flex !important; flex-flow:row wrap !important; align-items:center !important;
    align-content:center !important; height:auto !important; min-height:58px !important;
    padding:7px 12px !important; column-gap:8px !important; row-gap:5px !important;
  }
  #ms-studio-master-modal .studio-identity-main {
    order:1 !important; flex:1 1 0% !important; min-width:0 !important;
    max-width:100% !important; overflow:hidden !important;
  }
  #ms-studio-master-modal .studio-brand-logo,
  #ms-studio-master-modal .studio-brand-divider,
  #ms-studio-master-modal .studio-title-badge,
  #ms-studio-master-modal .studio-back-long { display:none !important; }
  #ms-studio-master-modal .studio-back-short { display:inline !important; }
  #ms-studio-master-modal #studio-design-name {
    flex:1 1 100px !important; width:auto !important; min-width:60px !important;
    max-width:none !important; overflow:hidden !important; text-overflow:ellipsis !important;
  }
  #ms-studio-master-modal .studio-primary-actions {
    order:2 !important; flex:0 0 auto !important; display:flex !important;
    max-width:none !important; min-width:0 !important; overflow:visible !important;
    margin-left:auto !important; padding:0 !important; gap:5px !important;
  }
  #ms-studio-master-modal .studio-menubar {
    order:3 !important; flex:1 1 100% !important; width:100% !important;
    min-width:0 !important; display:flex !important; flex-wrap:wrap !important;
    align-items:center !important; overflow:visible !important; gap:3px !important;
  }
}
@media (max-width:440px) {
  /* On small phones Save, Publish and the Tools entry remain accessible;
     Undo/Redo remain available from the editor's Edit menu. */
  #ms-studio-master-modal .studio-history-actions { display:none !important; }
  #ms-studio-master-modal .studio-identity-main { min-width:0 !important; }
  #ms-studio-master-modal .studio-primary-actions { gap:3px !important; }
  #ms-studio-master-modal .studio-primary-actions > button { padding-inline:7px !important; }
}


/* Studio popup isolation — October 2026. One interactive layer at a time.
   Do not let the contextual text toolbar float over an open advanced editor. */
#ms-studio-master-modal:has(#studio-action-sheet) #studio-context-toolbar,
#ms-studio-master-modal:has(#studio-action-sheet) #studio-context-sheet,
#ms-studio-master-modal:has(#studio-action-sheet) .studio-mobile-selection-dock {
  display:none !important;
}
#ms-studio-master-modal #studio-action-sheet .studio-bulk-create-sections > section,
#ms-studio-master-modal #studio-action-sheet .studio-bulk-choice-grid > section {
  background:rgba(148,163,184,.06);
  border:1px solid rgba(148,163,184,.38);
  border-radius:16px;
  padding:16px;
  min-width:0;
}
#ms-studio-master-modal #studio-action-sheet .studio-bulk-create-sections > section > h3,
#ms-studio-master-modal #studio-action-sheet .studio-bulk-choice-grid > section > h3 {
  font-size:15px;
  font-weight:800;
  margin:0 0 12px;
  line-height:1.25;
}
#ms-studio-master-modal #studio-action-sheet .studio-bulk-create-sections p,
#ms-studio-master-modal #studio-action-sheet .studio-bulk-choice-grid p {
  font-size:13px;line-height:1.5;opacity:.8;margin:0 0 12px;
}
@media (max-width:768px) {
  #ms-studio-master-modal #studio-action-sheet.studio-sheet-dock {
    position:absolute !important;
    top:65px !important;
    bottom:100px !important;
    left:0 !important;
    right:0 !important;
    width:100% !important;
    max-height:none !important;
    height:auto !important;
    z-index:100001 !important;
    display:flex !important;
    flex-direction:column !important;
    align-items:stretch !important;
    justify-content:flex-end !important;
    padding:10px 12px !important;
    box-sizing:border-box !important;
    background:rgba(15,23,42,.44) !important;
    backdrop-filter:blur(6px) !important;
    overflow:hidden !important;
  }
  #ms-studio-master-modal #studio-action-sheet.studio-sheet-dock > section {
    display:flex !important;
    flex-direction:column !important;
    flex:0 1 auto !important;
    height:auto !important;
    min-height:0 !important;
    width:100% !important;
    max-height:100% !important;
    max-width:none !important;
    border-radius:22px !important;
    box-shadow:0 16px 45px rgba(0,0,0,.22) !important;
    overflow:hidden !important;
  }
  #ms-studio-master-modal #studio-action-sheet.studio-sheet-dock > section > header {
    position:sticky !important;top:0 !important;z-index:3 !important;
    flex:0 0 auto !important;background:#fff !important;
    padding:14px 16px !important;
    border-bottom:1px solid #cbd5e1 !important;
  }
  html.dark #ms-studio-master-modal #studio-action-sheet.studio-sheet-dock > section > header {
    background:#0f172a !important;border-bottom-color:#334155 !important;
  }
  #ms-studio-master-modal #studio-action-sheet.studio-sheet-dock > section > div {
    flex:1 1 auto !important;min-height:0 !important;
    overflow-y:auto !important;overscroll-behavior:contain !important;
    -webkit-overflow-scrolling:touch !important;padding:16px !important;
  }
}

/* Compact symbol on phones; desktop and tablets keep the full wordmark. */
#ms-studio-master-modal .studio-brand-mark{display:none!important}
@media(max-width:768px){
  #ms-studio-master-modal .studio-identity-main .studio-brand-mark{
    display:block!important;width:26px!important;height:26px!important;
    min-width:26px!important;max-width:26px!important;
    flex:0 0 26px!important;object-fit:contain!important;
    opacity:1!important;visibility:visible!important;position:static!important;
    margin:0 3px!important;
  }
  #ms-studio-master-modal .studio-identity-main .studio-brand-logo{display:none!important}
}


/* Editing dialogs: explicit visual hierarchy between independent control areas. */
#ms-studio-master-modal #studio-action-sheet[data-studio-sheet-type="editing"] > section > div > section,
#ms-studio-master-modal #studio-action-sheet[data-studio-sheet-type="editing"] > section > div > div > section {
  display:grid;
  gap:10px;
  padding:14px;
  margin:0 0 12px;
  border:1px solid rgba(148,163,184,.36);
  border-radius:14px;
  background:rgba(148,163,184,.06);
  min-width:0;
}
#ms-studio-master-modal #studio-action-sheet[data-studio-sheet-type="editing"] label{
  display:block;min-width:0;line-height:1.4;
}
#ms-studio-master-modal #studio-action-sheet[data-studio-sheet-type="editing"] input,
#ms-studio-master-modal #studio-action-sheet[data-studio-sheet-type="editing"] select,
#ms-studio-master-modal #studio-action-sheet[data-studio-sheet-type="editing"] textarea{
  max-width:100%;
}
