@layer layout {
  #app { display: grid; grid-template-rows: var(--bar-h) minmax(0, 1fr) 28px; height: 100%; }

  .topbar, .status { display: flex; align-items: center; gap: var(--s-2); background: var(--bg-2); border-bottom: 1px solid var(--line); padding: 0 var(--s-3); }
  .topbar { z-index: 30; }
  .brand { font-weight: 700; letter-spacing: .3px; margin-right: var(--s-3); color: var(--accent); font-size: 15px; }
  .status { border-bottom: 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-dim); gap: var(--s-4); }
  .status .cell { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

  .workspace { display: grid; grid-template-columns: var(--tool-w) minmax(0, 1fr) 6px var(--dock-w); min-height: 0; }
  .toolbar { display: flex; flex-direction: column; align-items: center; overflow-x: hidden; gap: var(--s-1); padding: var(--s-2) 0; background: var(--bg-2); border-right: 1px solid var(--line); overflow-y: auto; }
  .tool-group { display: grid; grid-template-columns: repeat(2, 38px); gap: 2px; padding-bottom: var(--s-2); margin-bottom: var(--s-1); border-bottom: 1px solid var(--line); }
  .tool-group:last-of-type { border-bottom: 0; }

  .stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--stage); }
  .tabs { display: flex; align-items: flex-end; gap: 2px; padding: 4px 8px 0; background: var(--bg-2); border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
  .canvas-wrap { position: relative; flex: 1; min-height: 0; }
  #viewport { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

  .dock { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; background: var(--bg-2); border-left: 1px solid var(--line); }
  .grow-panel { flex: 1 1 auto; min-height: 220px; display: flex; flex-direction: column; }
  .grow-panel .panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

  /* splitter between the picture area and the side panels: drag to resize, double-click or the arrow to collapse */
  .dock-split { position: relative; z-index: 6; cursor: col-resize; background: var(--bg-2); border-left: 1px solid var(--line); touch-action: none; }
  .dock-split:hover, .dock-split.dragging { background: var(--accent); }
  .dock-split .dock-toggle { position: absolute; left: -9px; top: 50%; transform: translateY(-50%); width: 16px; height: 42px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); color: var(--text-dim); cursor: pointer; opacity: .75; }
  .dock-split .dock-toggle:hover { opacity: 1; color: var(--text); background: var(--bg-3); }
  .dock-split .dock-toggle svg { transition: transform .15s; }
  .dock-collapsed .dock-split .dock-toggle svg { transform: scaleX(-1); }
  .dock-collapsed .dock { visibility: hidden; border-left: 0; }
  .dock-resizing, .dock-resizing * { cursor: col-resize !important; user-select: none; }

  .hide-sm { display: initial; }
  .show-sm { display: none; }

  @media (max-width: 920px) {
    .workspace { grid-template-columns: var(--tool-w) minmax(0, 1fr); }
    .dock-split { display: none; }
    .dock-collapsed .dock { visibility: visible; }
    .dock { position: fixed; right: 0; top: calc(var(--bar-h) + 40px); bottom: 28px; width: min(292px, 88vw); z-index: 25; transform: translateX(100%); transition: transform .18s ease; box-shadow: var(--shadow); }
    #app.dock-open .dock { transform: none; }
    .hide-sm { display: none !important; }
    .show-sm { display: inline-flex; }
    .brand { margin-right: var(--s-1); }
  }
}
