/* Workspace placement only; tool card styles are shared with Studio. */
/* Dash mounts the canvas before the session callback can place and initialize
   it. Never expose that intermediate tree as a second layout below the page.
   Keep it measurable so Plotly and the preview scaler can finish while hidden. */
.sp-editor-host { position: fixed; visibility: hidden; color: var(--sp-text); font-family: var(--sp-font-ui); min-width: 0; }
.sp-editor-host.is-placed[data-mode] { visibility: visible; }
.sp-editor-host.is-placed {
  position: fixed; left: var(--editor-host-left); top: var(--editor-host-top);
  width: var(--editor-host-width); height: var(--editor-host-height); z-index: 5;
  display: flex; flex-direction: column; background: var(--sp-bg); overflow: hidden;
}
#editor-workspace-status { color: var(--sp-text-3); font-size: 12px; line-height: 18px; }
#editor-workspace-content, .sp-editor-workspace { min-height: 0; min-width: 0; flex: 1; }
.is-placed > #editor-workspace-content, .is-placed .sp-editor-workspace { display: flex; flex-direction: column; }
.sp-editor-workspace .sp-editor-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 0; }
.sp-editor-workspace button:not([class*="mantine-"]), .sp-editor-actions a {
  font: 600 13px var(--sp-font-ui); color: var(--sp-text); background: var(--sp-surface);
  border: 1px solid var(--sp-border-strong); border-radius: 8px; padding: 7px 12px; cursor: pointer;
}
.sp-editor-workspace button:disabled { opacity: .45; cursor: default; }
.sp-editor-workspace button:focus-visible { outline: 2px solid var(--sp-accent); outline-offset: 2px; }
.sp-editor-workspace #editor-save { margin-left: auto; background: var(--sp-accent); color: var(--sp-on-accent); border-color: var(--sp-accent); }
.sp-editor-workspace .sp-preview-stage-wrap { position: relative; }
.sp-editor-preview-refresh {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  z-index: 20; pointer-events: none; animation: editor-refresh-appear .15s .35s both;
}
.sp-editor-preview-refresh[hidden] { display: none; }
@keyframes editor-refresh-appear { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sp-editor-preview-refresh { animation: none; } }
.sp-editor-workspace .sp-editor-columns { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 20px; min-height: 0; flex: 1; }
.sp-editor-workspace .sp-editor-canvas-column { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.sp-editor-workspace #editor-tools { width: 340px; max-width: 100%; min-height: 0; }
.is-placed #editor-tools { display: flex; flex-direction: column; overflow: hidden; border-left: 1px solid var(--sp-border); padding-left: 16px; animation: editor-panel-in .18s ease-out; }
.is-placed #editor-tool-content { overflow: auto; overscroll-behavior: contain; flex: 1; min-height: 0; padding: 12px 4px 12px 0; }
.sp-editor-fine-tuning-switch { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#editor-tools:has(#editor-inspector-pro-toggle:focus-visible) .sp-ft-unlock { outline: 2px solid var(--sp-accent); outline-offset: 2px; }
.sp-editor-settings-actions { display: flex; gap: 8px; padding-top: 8px; flex-shrink: 0; }
.sp-editor-settings-actions > button { flex: 1; }
.sp-editor-workspace #editor-open-export { background: var(--sp-accent); color: var(--sp-on-accent); border-color: var(--sp-accent); }
#editor-back-settings { display: none; }
#editor-tools:has(#editor-tool-content > :not(#editor-panel-text)) #editor-back-settings { display: block; }
#editor-fine-tuning-content:empty::before {
  content: 'Loading fine-tuning…'; display: block; padding: 16px;
  color: var(--sp-text-3); font-size: 13px;
}
#editor-tools:has(:is(#editor-panel-export, #editor-panel-presets)) .sp-editor-settings-actions { display: none; }
.sp-editor-workspace .sp-inspector-simple .sp-pro-only { display: none; }
.sp-editor-workspace .sp-editor-tool-group { display: grid; gap: 12px; min-width: 0; }
.sp-editor-workspace .sp-editor-view-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.sp-editor-workspace #editor-btn-apply-filters { flex-shrink: 0; margin-top: 8px; }
.sp-editor-workspace #editor-figure-card { padding: 0 !important; background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.is-placed #editor-figure-card { flex: 1; min-height: 0; display: flex !important; flex-direction: column; }
.is-placed .sp-preview-workbench { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0,1fr); align-items: center; }
.sp-editor-workspace .sp-preview-stage-wrap { width: 100%; min-width: 0; --sp-preview-height-reserve: 106px; }
.sp-editor-workspace .sp-preview-stage-wrap.sp-preview-scaled { height: var(--sp-preview-stage-clamp-h); max-height: var(--sp-preview-stage-clamp-h); min-height: 0; overflow: hidden; }
.sp-editor-workspace .sp-preview-stage-wrap.sp-preview-scaled > .sp-editor-canvas-stage { transform: translateX(var(--sp-preview-stage-offset-x,0px)) scale(var(--sp-preview-scale,1)); transform-origin: top left; }
.sp-editor-workspace .sp-section-layout-editor[data-chrome-visible="false"] .sp-section-layout-box { visibility: hidden; }
.sp-editor-host[data-mode="browse"] .sp-editor-view-toolbar,
body:where([data-sp-has~="explore-enter"]):not(#sp-s) .sp-editor-host[data-mode="browse"][data-chrome="explore"] .sp-editor-actions,
.sp-editor-host[data-mode="browse"] #editor-workspace-status { display: none; }
.sp-editor-host[data-mode="design"] #editor-enter { display: none; }
.sp-editor-workspace .sp-editor-canvas-column.is-fullscreen { position: fixed; inset: 0; z-index: 2000; padding: 20px; overflow: auto; background: var(--sp-bg); }
.sp-editor-host:has(.is-fullscreen) { z-index: 2100; }
.sp-editor-workspace .is-fullscreen .sp-editor-view-toolbar { display: none; }
.sp-editor-workspace .is-fullscreen .sp-preview-stage-wrap { --sp-preview-height-reserve: 110px; }
.sp-editor-workspace #editor-exit-dialog {
  box-sizing: border-box; width: 560px; max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain;
  margin: auto; padding: 0; border: 1px solid var(--sp-border-soft);
  border-radius: var(--sp-radius-card); background: var(--sp-surface-panel);
  color: var(--sp-text-primary); box-shadow: 0 24px 80px rgb(0 0 0 / .3);
  font-family: var(--sp-font-ui); text-align: left;
}
#editor-exit-dialog::backdrop { background: var(--sp-scrim); }
/* Reuse Explore's export sheet above the fixed, clipped workspace. Native
   dialog supplies focus containment, Escape dismissal and focus restoration. */
#editor-export {
  --cmp-chrome: var(--sp-surface-panel); --cmp-border: var(--sp-border-soft);
  --cmp-text: var(--sp-text-primary); --cmp-muted: var(--sp-text-muted);
  --cmp-ui: var(--sp-font-ui); --cmp-display: var(--sp-font-display);
  box-sizing: border-box; width: 100%; max-width: none; height: 100%; max-height: none;
  margin: 0; padding: 0; border: 0; background: transparent; color: var(--sp-text);
}
#editor-export::backdrop { background: transparent; }
#editor-export .cmp-export-scrim { border: 0; border-radius: 0; padding: 0; background: var(--sp-scrim); }
#editor-export .cmp-export-card { box-sizing: border-box; }
#editor-export #editor-save-card { margin: 0; padding: 0; border: 0; box-shadow: none; background: transparent; }
#editor-export .sp-export-form { display: grid; gap: 20px; }
#editor-export .sp-export-output-summary { color: var(--sp-text-muted); font-size: 14px; line-height: 1.5; }
#editor-export .sp-export-quality-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
#editor-export .sp-export-quality-options .mantine-Radio-root { padding: 12px; border: 1px solid var(--sp-border-soft); border-radius: 8px; }
#editor-export .sp-export-quality-options .mantine-Radio-root:last-child { grid-column: 1 / -1; }
#editor-export .sp-export-quality-options .mantine-Radio-root:has(input:checked) { border-color: var(--sp-accent); }
#editor-export .sp-export-quality-options .mantine-Radio-description { color: var(--sp-text-muted); line-height: 1.45; margin-top: 5px; }
#editor-export .sp-export-quality-options .mantine-Radio-label { font-weight: 600; cursor: pointer; }
#editor-export .sp-export-frame-rate-field { display: grid; gap: 8px; }
#editor-export .sp-export-field-label { color: var(--sp-text-primary); font-size: 14px; font-weight: 600; }
#editor-export .sp-export-frame-rate .mantine-SegmentedControl-label { min-height: 44px; display: flex; align-items: center; justify-content: center; }
#editor-export #editor-video-export-fps .mantine-SegmentedControl-label[data-active] { background: var(--sp-selected-bg); color: var(--sp-selected-text) !important; border-radius: 6px; }
#editor-export #editor-video-export-fps .mantine-SegmentedControl-indicator { background: transparent !important; box-shadow: none !important; }
#editor-export .sp-export-help { margin: 0; color: var(--sp-text-muted); font-size: 13px; line-height: 1.55; }
#editor-export .sp-export-submit { min-height: 46px; background: var(--sp-accent); color: var(--sp-on-accent); border: 0; border-radius: 8px; font-weight: 700; }
#editor-export .sp-export-submit:hover { background: var(--sp-accent-hover); }
#editor-export .sp-export-submit:disabled { opacity: .5; cursor: wait; }
#editor-export .sp-export-disclosure { font-size: 13px; color: var(--sp-text-primary); }
#editor-export .sp-export-disclosure > summary { padding: 10px 0; cursor: pointer; min-height: 44px; box-sizing: border-box; }
#editor-export .sp-export-disclosure > summary:focus-visible { outline: 2px solid var(--sp-accent); outline-offset: 2px; }
#editor-export .sp-export-extra-quality, #editor-export .sp-export-settings-grid { display: grid; gap: 12px; padding: 8px 0; }
#editor-export .sp-export-disclosure > .mantine-CheckboxGroup-root { margin-bottom: 12px; }
#editor-export #editor-export-video-feedback:empty, #editor-export #editor-save-feedback:empty { display: none; }
#editor-exit-dialog .sp-editor-exit-body { padding: 24px; }
#editor-exit-title { margin: 0 0 12px; font: 600 20px/1.3 var(--sp-font-ui); letter-spacing: -.02em; }
#editor-exit-description { margin: 0; font-size: 14px; line-height: 1.6; }
#editor-exit-progress { margin: 12px 0 0; color: var(--sp-text-muted); font-size: 13px; line-height: 1.6; }
#editor-exit-error { margin: 16px 0 0; padding: 12px; border: 1px solid var(--sp-border-soft); border-radius: 8px; font-size: 14px; line-height: 1.5; }
#editor-exit-dialog .sp-editor-exit-actions {
  display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end;
  gap: 8px; padding: 16px 24px; border-top: 1px solid var(--sp-border-soft);
}
#editor-exit-dialog .sp-editor-exit-actions button {
  min-height: 44px; padding: 10px 12px; line-height: 1.4;
  background: transparent; color: var(--sp-text-primary); border-color: var(--sp-border-soft);
}
#editor-exit-dialog #editor-exit-stay { margin-right: auto; border-color: transparent; }
#editor-exit-dialog .sp-editor-exit-actions button:hover { background: var(--sp-surface-soft); }
#editor-exit-dialog #editor-exit-keep { background: var(--sp-accent); border-color: var(--sp-accent); color: var(--sp-on-accent); }
#editor-exit-dialog #editor-exit-keep:hover { background: var(--sp-accent-hover); border-color: var(--sp-accent-hover); }
@media (max-width: 575px) {
  #editor-exit-dialog .sp-editor-exit-body { padding: 20px; }
  #editor-exit-dialog .sp-editor-exit-actions { flex-direction: column; align-items: stretch; padding: 16px 20px; }
  #editor-exit-dialog #editor-exit-stay { margin-right: 0; border-color: var(--sp-border-soft); }
}
.sp-editor-workspace-anchor { width: 100%; min-height: 240px; }
#compare-shell:has(#editor-workspace-anchor) .cmp-legend { display: none; }
body:where([data-sp-has~="editor-explore-design"]):not(#sp-s):not(.sp-s):not(.sp-s):not(.sp-s) .cmp-cta-wrap { display: none; }
/* Desktop keeps the workspace in the viewport; mobile restores page flow below. */
#app-page-container:has(#editor-workspace-anchor) { height: calc(100dvh - var(--sp-header-h)); min-height: 0; overflow: hidden; box-sizing: border-box; }
.sp-editor-host.is-placed[data-origin="studio"] { padding: 12px 16px; }
@keyframes editor-panel-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .is-placed #editor-tools { animation: none; } }
@media (max-width: 599px), (max-width: 767px) and (max-aspect-ratio: 10/13) {
  /* Match Studio's mobile surface: one page scroll, preview then tools.
     Placement reserves this host's natural height in the route-owned anchor. */
  .sp-editor-host.is-placed { position: absolute; height: auto; overflow: visible; }
  #app-page-container:has(#editor-workspace-anchor) { height: auto; overflow: visible; }
  .is-placed > #editor-workspace-content, .is-placed .sp-editor-workspace { flex: none; }
  .sp-editor-workspace .sp-editor-columns { grid-template-columns: minmax(0,1fr); gap: 8px; }
  .is-placed .sp-editor-columns { flex: none; }
  .is-placed #editor-figure-card, .is-placed .sp-preview-workbench { flex: none; }
  /* Both modes scroll: scale to the available width, preserving proportions. */
  .sp-editor-workspace .sp-preview-stage-wrap { --sp-preview-height-reserve: none; }
  /* Only the preview bleeds to the screen edges; controls keep their gutters.
     Override the canvas shell's inline card width and auto margins. */
  .sp-editor-host[data-chrome="explore"] .sp-editor-canvas-column:not(.is-fullscreen) #editor-figure-card {
    width: 100vw !important; max-width: none !important; margin-inline: calc((100% - 100vw) / 2) !important;
  }
  .sp-editor-workspace #editor-tools { width: 100%; }
  .is-placed #editor-tools { overflow: visible; border-left: 0; padding: 12px 0; animation: none; }
  .is-placed #editor-tool-content { overflow: visible; flex: none; padding-right: 0; }
  .is-placed .is-fullscreen #editor-figure-card, .is-placed .is-fullscreen .sp-preview-workbench { flex: 1; }
  .sp-editor-workspace .sp-editor-actions { gap: 4px; }
  .sp-editor-workspace #editor-preview-format-mode { display: none; }
  .sp-editor-workspace .sp-editor-view-toolbar { gap: 8px; }
  .sp-editor-workspace .sp-editor-canvas-column.is-fullscreen { padding: 10px; }
}
