/* Story 2692 - the unified screen: a global top bar, a left pane that edits, a right pane that is
   always the preview. Everything is scoped to ws- classes or to body.ws-on. */

.ws-frame[hidden], .ws-stage[hidden], .ws-aux[hidden] { display: none !important; }

/* The global top bar. */
.ws-frame {
  display: flex; align-items: center; gap: 10px; padding: 6px 14px; min-height: 40px; box-sizing: border-box;
  background: var(--panel); border-bottom: 1px solid var(--line-dark);
}
.ws-place { font-size: 15px; color: var(--ink); max-width: 260px; display: inline-block; vertical-align: bottom; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-menu-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ws-menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; font: inherit; color: var(--ink);
  background: transparent; border: 0; border-radius: 8px; padding: 7px 8px; cursor: pointer;
}
.ws-menu-item:hover:not(:disabled), .ws-menu-item:focus-visible { background: var(--teal-soft); }
.ws-menu-item.current { box-shadow: inset 3px 0 0 var(--teal); }
.ws-menu-item:disabled { opacity: .55; cursor: default; }
.ws-card-icon { font-size: 20px; flex: none; }
.ws-card-icon img { width: 28px; height: 28px; }
.ws-card-text { display: grid; min-width: 0; }
.ws-card-text small { color: var(--muted); font-size: 12px; }
body.ws-on #bin-actions { display: none !important; }

/* Two persistent panes beneath the bar: about 40% left, the preview keeps the rest. */
body.ws-on .app-shell { height: calc(100vh - 79px - var(--ws-chrome, 0px)); }

/* The right pane is only ever the preview of the whole Space while one is open. */
body.ws-on.ws-open .view-tabs,
body.ws-on.ws-open #preview-state,
body.ws-on.ws-open .workspace-footer,
body.ws-on.ws-open .canvas-wrap[data-canvas="drawer"] .dl-hint { display: none !important; }
body.ws-on.ws-open:not(.ws-task-settings) #drawer-canvas { cursor: pointer; }
/* Story 2704: the open screen has nothing selected, so the right pane shows no preview. */
body.ws-on.ws-task-picker:not(.ws-open) .workspace { visibility: hidden; }
/* Layout and nothing-selected show the existing print list beneath the one bin tree. */
body.ws-on.ws-task-none .controls > :not(#ws-tree):not(#drawer-panel),
body.ws-on.ws-task-settings .controls > :not(#ws-tree):not(#drawer-panel):not(#space-head),
body.ws-on.ws-task-none #ws-aux,
body.ws-on.ws-task-settings #ws-aux,
body.ws-on.ws-task-none #drawer-panel > #dl-space-details-card,
body.ws-on.ws-task-none #drawer-panel > .dl-savebar,
body.ws-on.ws-task-settings #drawer-panel > #dl-space-details-card,
body.ws-on.ws-task-settings #drawer-panel > .dl-savebar { display: none !important; }

/* The ordinary editor already lives in these control sections, outside #drawer-panel.
   Peek exposes that same form; the print list and other Space chrome step aside. */
body.ws-on.ws-task-peek .controls > :not(#ws-tree):not(.control-section),
body.ws-on.ws-task-peek #space-head,
body.ws-on.ws-task-peek #ws-aux { display: none !important; }
.ws-stage.receiving, .ws-tree.receiving { background: var(--teal-soft); box-shadow: inset 0 0 0 2px var(--teal); }

/* (A) the selector header: pinned at a fixed height above the scrolling pane. (B) is .controls below it. */
.ws-left { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; overflow: hidden; container-type: size; }
.ws-left > .ws-stage {
  flex: none; height: 72px; overflow: hidden; box-sizing: border-box;
  display: flex; flex-direction: column;
  background: #f8faf9; border-bottom: 2px solid var(--line-dark);
}
.ws-left > .controls { flex: 1 1 auto; min-height: 0; }
@media (max-width: 980px) {
  /* Story 3533: stacked, the shell grows with the form so the preview takes its own band below it. */
  body.ws-on .app-shell { height: auto; }
  .ws-left { height: auto; overflow: visible; container-type: normal; }
}
/* Story 3162: one fixed line for the status message, present whether or not a message is showing; long text truncates without shifting content. */
.ws-status-slot { flex: none; height: 20px; line-height: 20px; overflow: hidden; }
.ws-status-slot > p { margin: 0; font-size: 12px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-sel { padding: 8px 12px 6px; display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.ws-sel > .ws-sel-head { flex: none; }
.ws-sel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 30px; margin: 0 0 4px; }
.ws-sel-head h2 { margin: 0; font-size: 14pt; font-weight: 700; color: var(--ink); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-sel-actions { display: flex; flex-wrap: nowrap; gap: 6px; flex: none; }
.ws-tree { padding: 8px 12px 10px; background: #f8faf9; border-bottom: 1px solid var(--line-dark); }
/* Story 3276: where an editor shares the left column, the selection tree takes at most a third of that column's height
   (33cqh of .ws-left; 33vh where the column is auto-height below 980px) and its rows scroll inside it. */
/* Story 3333: the tree never scrolls sideways; its rows fit the panel (see .ws-items and .ws-row). */
.ws-tree { box-sizing: border-box; max-height: 33vh; max-height: 33cqh; overflow-y: auto; overflow-x: hidden; }
.ws-tree[hidden] { display: none !important; }
/* The tree keeps the whole column when it stands alone: the home picker, and a task with no editor shown. */
body.ws-task-picker #ws-tree,
body.ws-on.ws-task-none #ws-tree { max-height: none; }
/* Story 3333: one column exactly as wide as the tree, so a row can never widen the tree. */
.ws-items { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
/* Story 3333: the row's name gives way first; the buttons keep their size and only move to a second line
   if the panel is too narrow for them all, so they are never cut off. */
.ws-row { display: flex; flex-wrap: wrap; align-items: stretch; gap: 4px; min-width: 0; }
.ws-row > .ws-rowbtn { flex: 1 1 0; width: auto; min-width: 0; }
.ws-row > .ws-row-settings { flex-basis: 100%; }
.ws-out { flex: none; white-space: nowrap; font: inherit; font-size: 13px; font-weight: 700; background: white; border: 1px solid var(--line-dark); border-radius: 8px; padding: 3px 10px; cursor: pointer; color: #111; }
.ws-out:hover:not(:disabled) { border-color: var(--teal); background: var(--teal-soft); }
.ws-out.printed { color: #0b6b2a; }
.ws-out.unprinted { color: #111; }
.ws-out:disabled { cursor: default; background: #f4f6f6; }
.ws-out.printed:disabled { color: #4f7f5e; }
.ws-out.unprinted:disabled { color: #55585a; }
.ws-rowbtn {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--ink); background: white; border: 1px solid var(--line-dark); border-radius: 8px; padding: 5px 10px; cursor: pointer; min-height: 30px;
}
.ws-rowbtn:hover:not(:disabled) { border-color: var(--teal); background: var(--teal-soft); }
.ws-rowbtn:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.ws-rowbtn:disabled { cursor: default; opacity: .7; }
.ws-rowbtn.selected { background: var(--teal-soft); border-color: var(--teal); box-shadow: inset 3px 0 0 var(--teal); color: var(--teal-dark); }
/* Story 3133: a row's name (the storage box's name and dimensions) wraps instead of clipping. */
.ws-label { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.ws-space-line { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; }
.ws-space-line > .ws-menu-item { flex: 1 1 auto; width: auto; min-width: 0; }
.ws-space-line > .ws-space-act { flex: none; }
.ws-ai-here { display: contents; }
/* Story 3333: the measurements stay whole (they wrap rather than clip) and end about 1.5in left of the row's right edge;
   the name beside them takes the room that is left. */
.ws-rowbtn > .ws-label { flex: 1 1 0; }
.ws-note { flex: 0 1 auto; min-width: 0; margin-left: auto; margin-right: 1.5in; font-size: 12px; font-weight: 400; color: var(--muted); white-space: normal; overflow-wrap: anywhere; text-align: right; }
.ws-group { font-size: 12px; font-weight: 700; color: var(--muted); margin-top: 4px; }
/* The hierarchy shows by indentation: container a third of an inch in, bins two-thirds of an inch in (Story 2840). */
.ws-row.ws-level-1 { margin-left: .33in; }
.ws-row.ws-level-2 { margin-left: .67in; }
.ws-empty { color: var(--ink); font-size: 13px; padding: 4px 0; }
.ws-first-bin-guide { animation: ws-first-bin-bounce 2.4s ease-in-out infinite; }
@keyframes ws-first-bin-bounce {
  0%, 100%, 28% { transform: translateY(0); }
  10% { transform: translateY(-4px); }
  18% { transform: translateY(0); }
  23% { transform: translateY(-2px); }
}

/* Print Space and New Space take the editor region (B) for a while. */
.ws-aux { padding: 12px 14px 20px; }
.ws-page h2 { margin: 0 0 8px; font-size: 18px; }
.ws-toprow { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; }
.ws-aux .ws-item, .ws-aux .ws-group { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.ws-aux .ws-item > label {
  display: flex; align-items: center; gap: 8px; width: 100%; cursor: pointer; box-sizing: border-box;
  background: white; border: 1px solid var(--line-dark); border-radius: 8px; padding: 5px 10px;
}
.ws-item input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: var(--teal); flex: none; }
.ws-printcount { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--teal-dark); }
.ws-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ws-choice {
  display: grid; gap: 4px; justify-items: start; width: 100%; text-align: left; font: inherit; color: var(--ink); background: white; cursor: pointer;
  border: 1px solid var(--line-dark); border-radius: 11px; padding: 10px 12px;
}
.ws-choice:hover { border-color: var(--teal); background: var(--teal-soft); }
.ws-choice:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.ws-choice img { width: 100%; max-width: 120px; height: 90px; object-fit: contain; }
.ws-choice small { color: var(--muted); font-size: 12px; }
.ws-links { margin: 8px 4px 0; font-size: 13px; color: var(--muted); }
.ws-space-def { margin: 0 0 10px; font-size: 13px; line-height: 1.45; color: var(--muted); }

/* Print Space / New Space show only their own editor under the selector. */
body.ws-task-print .controls > :not(#ws-tree):not(#ws-aux),
body.ws-task-newspace .controls > :not(#ws-tree):not(#ws-aux),
body.ws-task-picker .controls > :not(#ws-tree):not(#ws-aux) { display: none !important; }
/* Story 3182 / 3292: Manage Spaces keeps the spaces list scrollable and the New Space options pinned at the bottom. */
body.ws-task-picker .controls { display: flex; flex-direction: column; overflow: hidden; }
body.ws-task-picker #ws-tree { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
body.ws-task-picker #ws-aux { flex: none; }
/* Story 3262: the spaces list's loading row, shown from the Manage Spaces click until the read lands. */
.ws-spaces-loading { display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: var(--muted); font-size: 13px; }

/* Each editor stands alone: only its own part of the sidebar shows. */
body.ws-task-bin #space-head,
body.ws-task-container #space-actions > .button-row { display: none; }
/* Story 3362: keep the Layout container-size group as a complete, plain box below the tree. */
body.ws-task-container #space-fields-drawer:not([hidden]),
body.ws-task-settings #space-fields-drawer:not([hidden]) {
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: none;
}
/* The shared size readout has its own teal accent; keep the Layout container group plain. */
body.ws-task-container #space-fields-drawer .derived-readout,
body.ws-task-settings #space-fields-drawer .derived-readout {
  border-left: 1px solid var(--line);
}
body.ws-task-settings #space-head {
  padding: 6px 10px;
  border-left: 1px solid var(--line-dark);
}
body.ws-task-settings #space-actions { margin-top: 0; }
body.ws-task-settings #space-head-edit-host { margin-top: 8px; }
body.ws-task-settings .space-head-edit-host .space-buttons { display: none; }
body.ws-task-settings .space-head-edit-host .space-buttons:has(#space-edit-done:not([hidden])) { display: flex; }
body.ws-task-settings .space-head-edit-host .space-dimension-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
/* Space details reuse the setup form for name and usable size for every kind.
   Container construction settings remain in the container editor. */

/* Story 2743 / 2841: no empty bordered card above the details; the head shows only while it holds something
   visible (the kind's field group, an error or folder help). */
body.ws-task-settings #space-head:not(:has(
  #space-head-edit-host:not([hidden]), #space-actions,
  .space-type-fields:not([hidden]),
  #space-error:not([hidden]), #space-folder-help:not([hidden]))) { display: none; }

/* Story 2834: the same for the Storage box / Storage Drawers design view, where the title and the
   button row are hidden above; the empty card is not shown above "<kind> design". */
body.ws-task-container #space-head:not(:has(
  #space-structural:not([hidden]), #space-head-edit-host:not([hidden]),
  #space-error:not([hidden]), #space-folder-help:not([hidden]))) { display: none; }

/* Edit has no onboarding note. */
body.ws-task-settings #space-note { display: none !important; }

/* Big message in the middle section while switching views. */
.workspace { position: relative; }
.ws-switching {
  position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; text-align: center;
  background: rgba(248, 250, 249, .92); color: var(--teal-dark); font-size: 32px; font-weight: 700; pointer-events: all;
}
.ws-switching[hidden] { display: none; }

/* Space opening also covers the picker, whose workspace is hidden. */
.ws-opening {
  position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border: 0;
  align-items: center; justify-content: center;
  background: #f8faf9; color: var(--teal-dark); font-size: 32px; font-weight: 700; text-align: center;
}
.ws-opening[open] { display: flex; }

/* Setup is a full-screen task of its own. */
body.ws-on #welcome-dialog[open] {
  position: fixed; inset: 0; width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; border-radius: 0; overflow: auto;
}

/* Story 2747: New Space setup takes the left side, at the width of the editing column used for bins and Spaces. */
body.ws-on #welcome-dialog[open]:has(#space-form:not([hidden])) {
  inset: 0 auto 0 0; width: max(420px, min(var(--sidebar-width), calc(100vw - 448px))); max-width: 100vw;
}

/* Story 2735: while switching items the old preview is cleared; the Building geometry notice stands in. */
body.ws-item-switching .canvas-wrap > canvas { visibility: hidden; }

/* Story 2752: small drawer buttons in the Layout row. */
.ws-drawers { display: flex; gap: 4px; align-items: center; }
.ws-drawers-word { font-size: 12px; }
.ws-drawerbtn { min-width: 28px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: inherit; font-size: 12px; cursor: pointer; }
.ws-drawerbtn:hover:not(:disabled) { border-color: var(--teal); background: var(--teal-soft); }
.ws-drawerbtn.selected { font-weight: 700; border-color: var(--teal); box-shadow: inset 0 -3px var(--teal); }
.ws-drawerbtn:disabled { opacity: .5; cursor: default; }
