/* Pointer sizing is opt-in after the first resize/move. The initial window
   layouts retain their existing responsive sizing and palette. */
[data-desktop-canvas] .desktop-window[data-window-sized]:not(.is-maximized).is-open {
  display: flex;
  flex-direction: column;
}

[data-desktop-canvas] .desktop-window[data-window-sized]:not(.is-maximized) > .window-titlebar {
  flex: 0 0 auto;
}

[data-desktop-canvas] .desktop-window[data-window-sized]:not(.is-maximized) > .window-body,
[data-desktop-canvas] .desktop-window[data-window-sized]:not(.is-maximized) > .window-content {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  max-height: none;
  min-width: 0;
  margin-bottom: 16px;
  overflow-y: auto;
}

[data-desktop-canvas] [data-window-drag] {
  touch-action: none;
}

.desktop-window.is-dragging,
.desktop-window.is-resizing {
  user-select: none;
}

.desktop-window.is-resizing iframe {
  pointer-events: none;
}

.window-resize-handle {
  position: absolute;
  z-index: 12;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.window-resize-n { top: 0; left: 24px; right: 24px; height: 6px; cursor: ns-resize; }
.window-resize-s { bottom: 0; left: 24px; right: 24px; height: 7px; cursor: ns-resize; }
.window-resize-e { right: 0; top: 24px; bottom: 24px; width: 7px; cursor: ew-resize; }
.window-resize-w { left: 0; top: 24px; bottom: 24px; width: 7px; cursor: ew-resize; }
.window-resize-ne { top: 0; right: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.window-resize-nw { top: 0; left: 0; width: 6px; height: 6px; cursor: nwse-resize; }
.window-resize-sw { bottom: 0; left: 0; width: 16px; height: 16px; cursor: nesw-resize; }

.window-resize-se {
  bottom: 0;
  right: 0;
  width: 26px;
  height: 26px;
  cursor: nwse-resize;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: var(--window-control-text);
  background: linear-gradient(135deg, transparent 50%, var(--window-control-bg) 50%);
}

.window-resize-se::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 11px;
  height: 11px;
  background: repeating-linear-gradient(135deg, transparent 0 2px, currentColor 2px 3px, transparent 3px 5px);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.desktop-window.is-maximized > .window-resize-handle {
  display: none;
}

.window-resize-se:focus-visible {
  outline: 2px solid var(--highlight-ring);
  outline-offset: -2px;
}

@media (pointer: coarse) {
  .window-resize-handle:not(.window-resize-se) { display: none; }
  .window-resize-se { width: 44px; height: 44px; }
  .window-resize-se::after { width: 17px; height: 17px; right: 5px; bottom: 5px; }
  [data-desktop-canvas] .desktop-window[data-window-sized]:not(.is-maximized) > .window-body,
  [data-desktop-canvas] .desktop-window[data-window-sized]:not(.is-maximized) > .window-content {
    margin-bottom: 24px;
  }
}
