/* ============ window.css ============ */
.window {
  position: absolute; display: flex; flex-direction: column;
  min-width: 280px; min-height: 180px;
  background: var(--surface); backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden; color: var(--text);
  animation: win-open 0.18s cubic-bezier(.2,.9,.3,1);
  will-change: transform, width, height;
}
.window.minimizing { animation: win-min 0.22s ease forwards; }
.window.closing { animation: win-close 0.16s ease forwards; }
.window.maximized { border-radius: 0; }
.window.dragging, .window.resizing { transition: none !important; user-select: none; }
.window:not(.dragging):not(.resizing) { transition: box-shadow 0.2s; }
.window.inactive { box-shadow: var(--shadow-sm); }
.window.inactive .titlebar { opacity: 0.85; }

.titlebar {
  height: 38px; flex-shrink: 0; display: flex; align-items: center;
  padding: 0 6px 0 12px; cursor: default; gap: 8px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.04), transparent);
  border-bottom: 1px solid var(--border);
}
.titlebar .tb-icon { width: 18px; height: 18px; display: inline-flex; }
.titlebar .tb-icon svg, .titlebar .tb-icon img { width: 100%; height: 100%; }
.titlebar .tb-title { font-size: 13px; font-weight: 500; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titlebar .tb-controls { display: flex; gap: 2px; }
.tb-btn {
  width: 30px; height: 28px; border-radius: 7px; display: flex; align-items: center;
  justify-content: center; font-size: 14px; color: var(--text-dim); transition: background 0.12s, color 0.12s;
}
.tb-btn:hover { background: var(--hover); color: var(--text); }
.tb-btn.close:hover { background: #e0443e; color: #fff; }
.tb-btn svg { width: 12px; height: 12px; }

.window-body { flex: 1; overflow: auto; position: relative; }

/* resize handles */
.resize-handle { position: absolute; z-index: 20; }
.rh-n { top: -3px; left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.rh-s { bottom: -3px; left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.rh-e { right: -3px; top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.rh-w { left: -3px; top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.rh-ne { top: -4px; right: -4px; width: 14px; height: 14px; cursor: nesw-resize; }
.rh-nw { top: -4px; left: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
.rh-se { bottom: -4px; right: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
.rh-sw { bottom: -4px; left: -4px; width: 14px; height: 14px; cursor: nesw-resize; }
.window.maximized .resize-handle { display: none; }

/* snap preview */
#snap-preview {
  position: absolute; z-index: 9; pointer-events: none; border-radius: 12px;
  background: rgba(var(--accent-rgb), 0.22); border: 1.5px solid rgba(var(--accent-rgb), 0.7);
  transition: all 0.12s ease; backdrop-filter: blur(2px);
}
