/* Shadow Studio — 3-column, visual-first workstation.
   Page-scoped overrides; the original shadow engine, PFx Color picker and history stay intact. */
@scope (.pfx-shadow-studio) {
  .workspace.workspace--editor {
    width:min(100%,1500px);
    max-width:1500px;
    grid-template-columns:minmax(218px,270px) minmax(0,1fr) minmax(258px,305px);
    grid-template-rows:auto auto;
    align-items:start;
    gap:12px;
    padding:13px clamp(14px,2vw,26px) 40px;
  }
  .workspace--editor > .studio-heading {
    grid-column:1/-1;
    grid-row:1;
    padding:0 0 4px;
    margin:0;
    min-height:43px;
    gap:6px 13px;
  }
  .workspace--editor .studio-heading a { padding:6px 10px;margin:0; }
  .workspace--editor .studio-heading .eyebrow { margin:0; width:auto; }
  .workspace--editor .studio-heading h1 { font-size:clamp(22px,2.3vw,30px);line-height:1.15; }
  .workspace--editor .studio-heading p { margin:0 0 3px auto;max-width:230px;font-size:11px; }
  .workspace--editor > .left,
  .workspace--editor > .stage,
  .workspace--editor > .right {
    grid-row:2;
    min-width:0;
    min-height:0;
    border:1px solid var(--line);
    background:var(--panel);
    border-radius:9px;
    box-shadow:0 3px 10px #00000006;
  }
  .workspace--editor > .left { grid-column:1; display:flex;flex-direction:column;padding:17px 16px; }
  .workspace--editor > .stage {
    grid-column:2;
    display:flex;
    flex-direction:column;
    gap:0;
    position:sticky;
    top:calc(var(--pfx-site-header-height,78px) + 10px);
    padding:11px;
    background:var(--panel);
    isolation:isolate;
  }
  .workspace--editor > .right {
    grid-column:3;
    display:flex;
    flex-direction:column;
    padding:13px 14px 12px;
    /* Let the document scroll so every control remains accessible.
       A viewport-constrained sidebar hid Spread, Opacity and Inset. */
    position:static;
    max-height:none;
    overflow:visible;
  }

  /* Layers: priority actions and active layer stay visible. */
  .workspace--editor .left .panel-heading { align-items:center; }
  .workspace--editor .left .panel-heading h2 { font-size:19px;margin-top:3px; }
  .workspace--editor .left .short { margin:5px 0 15px;line-height:1.4; }
  .workspace--editor .left .select { min-height:40px; }
  .workspace--editor .left .stack-header { margin:20px 0 8px; }
  .workspace--editor .left .layer-list {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    gap:7px;
    max-height:min(44dvh,440px);
    overflow-y:auto;
    overscroll-behavior:contain;
    scrollbar-width:thin;
    scrollbar-color:var(--line) transparent;
  }
  .workspace--editor .left .layer { padding:9px; }
  .workspace--editor .left .layer-actions { padding-top:3px; }
  .workspace--editor .left .layer-actions button { min-height:31px; }
  .workspace--editor .left .panel-footer { margin-top:14px;padding-top:12px; }
  .workspace--editor .left .panel-footer .button { font-size:10px;min-height:36px; }

  /* Preview: all presentation controls sit inside the canvas, not above it. */
  .workspace--editor .stage-header {
    display:grid;
    grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);
    align-items:center;
    gap:10px;
    margin:0 2px 10px;
  }
  .workspace--editor .stage-header__title { justify-self:start;min-width:0; }
  .workspace--editor .stage-header .chip { justify-self:end; }
  .workspace--editor .stage-header .eyebrow { font-size:9px; }
  .workspace--editor .stage-header h2 { margin:2px 0 0;font-size:17px; }
  .workspace--editor .stage-header .chip { font-size:9px;padding:5px 9px; }
  .workspace--editor .canvas {
    position:relative;
    display:flex;
    flex:none;
    align-items:center;
    justify-content:center;
    aspect-ratio:auto;
    height:clamp(270px,calc(100dvh - 415px),540px);
    max-height:none;
    min-height:0;
    overflow:hidden;
    border:1px solid var(--line);
    border-radius:7px;
    isolation:isolate;
    background:#eae7df;
  }
  .workspace--editor .canvas-background {
    position:absolute;
    top:12px;
    right:12px;
    z-index:4;
    display:flex;
    align-items:center;
    gap:9px;
    margin:0;
    padding:7px 9px;
    border:1px solid #ebe7de;
    border-radius:6px;
    background:rgba(255,253,249,.91);
    box-shadow:0 4px 12px #0000000b;
    backdrop-filter:blur(6px);
  }
  .workspace--editor .canvas-background .swatch { width:24px;height:24px;min-width:24px; }
  .workspace--editor .stage-header .canvas-target {
    position:static;
    z-index:auto;
    left:auto;
    bottom:auto;
    transform:none;
    display:flex;
    justify-self:center;
    align-items:center;
    gap:1px;
    margin:0;
    padding:3px;
    border:1px solid var(--line);
    border-radius:6px;
    background:var(--panel2);
    box-shadow:none;
    white-space:nowrap;
  }
  .workspace--editor .canvas-target button {
    color:#35443c;
    min-height:35px;
    min-width:48px;
    padding:6px 11px;
    font-size:11px;
    border-radius:4px;
  }
  .workspace--editor .canvas-target button.active { background:#f6e7df;color:#20372e; }
  .workspace--editor .canvas-corner { right:12px;bottom:15px;font-size:8px;letter-spacing:.06em; }
  .workspace--editor .canvas .preview-card { width:min(64%,315px);height:174px;max-width:calc(100% - 50px); }
  .workspace--editor .preview-card[data-preview="button"] { width:185px;height:60px; }
  .workspace--editor .preview-card[data-preview="text"] { width:auto;max-width:calc(100% - 40px); }
  /* CSS export is always directly under the canvas and its copy button stays in view
     whenever the central stage is visible. */
  .workspace--editor .output {
    position:relative;
    flex:none;
    margin:10px 0 0;
    padding:11px 12px;
    background:var(--panel2);
    border:1px solid var(--line);
    border-radius:7px;
  }
  .workspace--editor .output-top { align-items:center;gap:10px; }
  .workspace--editor .output h2 { font-size:14px;margin:2px 0 0; }
  .workspace--editor .output .button {
    flex:none;
    min-height:37px;
    padding:7px 12px;
    font-size:11px;
    font-weight:750;
  }
  .workspace--editor .output pre {
    margin:7px 0 0;
    padding:8px 10px;
    max-height:90px;
    overflow:auto;
    border:1px solid var(--line);
    background:var(--panel);
    color:var(--text);
    font:10px/1.55 ui-monospace,SFMono-Regular,monospace;
    overflow-wrap:anywhere;
  }

  /* Properties: color workbench first, short precise sliders immediately below. */
  .workspace--editor .right #shadow-color-root { display:block;width:100%;min-width:0; }
  .workspace--editor .right .shadow-color-workbench {
    display:block;
    padding:0;
    margin:0;
    border:0;
    border-radius:0;
    box-shadow:none;
    background:transparent;
    min-width:0;
  }
  .workspace--editor .right .shadow-color-workbench__heading h2 { margin:3px 0 0;font-size:17px; }
  .workspace--editor .right .shadow-color-workbench__live { padding:4px 6px;font-size:8px; }
  .workspace--editor .right .shadow-color-workbench__sub { margin:4px 0 9px;font-size:10px; }
  .workspace--editor .right .shadow-color-workbench__plane { height:145px; }
  .workspace--editor .right .shadow-color-workbench__rail-label { margin:8px 0 4px; }
  .workspace--editor .right .shadow-color-workbench__hue { height:15px; }
  .workspace--editor .right .shadow-color-workbench__hex-row { margin-top:11px;gap:6px; }
  .workspace--editor .right .shadow-color-workbench__hex-row input { height:32px; }
  .workspace--editor .right .shadow-color-workbench__sample { height:32px; }
  .workspace--editor .right .shadow-color-workbench__preset-label { margin:10px 0 7px; }
  .workspace--editor .right .shadow-color-workbench__presets { gap:5px; }
  .workspace--editor .right .shadow-color-workbench__preset { height:23px; }
  .workspace--editor .right .shadow-color-workbench__help { display:none; }
  .workspace--editor .right .shadow-color-workbench__feedback { margin:1px 0 0;min-height:0; }
  .workspace--editor .properties-heading {
    display:flex;
    align-items:center;
    justify-content:space-between;
    flex-wrap:wrap;
    gap:4px 10px;
    margin-top:15px;
    padding:11px 0 8px;
    border-top:1px solid var(--line);
  }
  .workspace--editor .properties-heading h2 { font-size:15px;letter-spacing:-.03em;margin:2px 0 0; }
  .workspace--editor .properties-heading .short { font-size:10px;margin:0; }
  .workspace--editor .right .control { margin:0 0 8px; }
  .workspace--editor .right .control>div { gap:5px; }
  .workspace--editor .right .control label { font-size:11px; }
  .workspace--editor .right .numeric { padding:2px 4px;font-size:10px; }
  .workspace--editor .right .numeric input { width:3.1em; }
  .workspace--editor .right .control input[type="range"] { height:24px;margin:2px 0 0; }
  .workspace--editor .right .toggle-row { padding:10px 0;margin-top:0; }
  .workspace--editor .right .import-disclosure { margin-top:4px;padding-top:8px; }
  .workspace--editor .right .import-disclosure summary { min-height:38px;font-size:11px; }
  .workspace--editor .right .editor-message { margin:5px 0 0; }
  .workspace--editor .right .import-area textarea { min-height:65px; }

  @media(max-width:1160px) and (min-width:951px) {
    .workspace.workspace--editor {
      grid-template-columns:minmax(202px,235px) minmax(0,1fr) minmax(230px,260px);
      gap:10px;
      padding-inline:12px;
    }
    .workspace--editor > .left { padding:14px 12px; }
    .workspace--editor > .right { padding:12px 10px; }
    .workspace--editor .canvas-corner { display:none; }
    .workspace--editor .canvas .preview-card { width:min(74%,310px); }
  }

  /* Tablet: keep a wide preview, show controls in two separate columns below. */
  @media(max-width:950px) and (min-width:701px) {
    .workspace.workspace--editor {
      grid-template-columns:repeat(2,minmax(0,1fr));
      grid-template-rows:auto auto auto;
      gap:12px;
      padding:14px 16px 32px;
    }
    .workspace--editor > .studio-heading { grid-column:1/-1;grid-row:1; }
    .workspace--editor > .stage { grid-column:1/-1;grid-row:2;position:static; }
    .workspace--editor .canvas { height:clamp(340px,51vw,480px); }
    .workspace--editor > .left { grid-column:1;grid-row:3; }
    .workspace--editor > .right {
      grid-column:2;grid-row:3;
      position:static;max-height:none;overflow:visible;
    }
    .workspace--editor .left .layer-list { max-height:370px; }
  }

  @media(max-width:700px) {
    .workspace.workspace--editor {
      display:flex;
      flex-direction:column;
      gap:10px;
      padding:12px 12px 28px;
    }
    .workspace--editor > .studio-heading { order:0;width:100%;min-height:0;display:block;padding:0 0 2px; }
    .workspace--editor .studio-heading a { margin-bottom:8px; }
    .workspace--editor .studio-heading h1 { font-size:26px; }
    .workspace--editor .studio-heading p { margin:5px 0 0; }
    .workspace--editor > .stage { order:1;position:static;width:100%;padding:10px; }
    .workspace--editor .canvas { height:clamp(280px,88vw,440px);aspect-ratio:auto; }
    .workspace--editor .canvas-background { right:10px;top:10px;padding:5px 7px; }
    .workspace--editor .stage-header {
      grid-template-columns:minmax(0,1fr) auto;
      row-gap:8px;
    }
    .workspace--editor .stage-header__title { grid-column:1;grid-row:1; }
    .workspace--editor .stage-header .chip { grid-column:2;grid-row:1; }
    .workspace--editor .stage-header .canvas-target {
      grid-column:1/-1;
      grid-row:2;
      justify-self:center;
    }
    .workspace--editor .canvas-corner { display:none; }
    .workspace--editor .canvas .preview-card { max-width:calc(100% - 35px);width:min(78%,285px);height:145px; }
    .workspace--editor .output { margin-top:9px; }
    .workspace--editor > .mobile-tabs { order:2;display:flex;width:100%;margin:0; }
    .workspace--editor > .left,
    .workspace--editor > .right { order:3;width:100%;position:static;max-height:none;overflow:visible; }
    .workspace--editor > .left { display:none!important; }
    .workspace--editor.show-layers > .left { display:flex!important; }
    .workspace--editor.show-layers > .right { display:none!important; }
    .workspace--editor > .right { display:flex!important; }
    .workspace--editor.show-layers > .right { display:none!important; }
    .workspace--editor > .right #shadow-color-root { display:none!important; }
    .workspace--editor.show-color > .right #shadow-color-root { display:block!important; }
    .workspace--editor.show-color > .right .properties-heading,
    .workspace--editor.show-color > .right #controls,
    .workspace--editor.show-color > .right .import-disclosure { display:none!important; }
    .workspace--editor:not(.show-color) > .right .properties-heading,
    .workspace--editor:not(.show-color) > .right #controls { display:block; }
    .workspace--editor .right .shadow-color-workbench__plane { height:195px; }
    .workspace--editor .right .shadow-color-workbench__preset { height:31px; }
    .workspace--editor .right .shadow-color-workbench__help { display:block; }
    .workspace--editor .right .control { margin-bottom:13px; }
    .workspace--editor .left .layer-list { max-height:45dvh; }
    .workspace--editor .left .short { margin-bottom:14px; }
    .workspace--editor .right .import-disclosure { margin-top:10px; }
  }
  @media(max-width:375px) {
    .workspace--editor .canvas .preview-card { width:min(85%,260px); }
    .workspace--editor .canvas-background .swatch { width:21px;height:21px;min-width:21px; }
    .workspace--editor .canvas-target button { min-width:42px;padding:5px 8px;font-size:10px; }
    .workspace--editor .output .button { padding:6px 9px; }
  }
  @media(prefers-reduced-motion:reduce) {
    .workspace--editor .canvas-background,
    .workspace--editor .canvas-target { transition:none; }
  }
}
