/* window.css — 窗口管理器（Win10 风格：直角、活动窗口 accent 边框、46×32 扁平控制按钮） */
#windows-root { position: fixed; inset: 0 0 var(--taskbar-h, 40px) 0; z-index: 100; pointer-events: none; }
.win {
  position: absolute;
  display: flex; flex-direction: column;
  min-width: 320px; min-height: 200px;
  background: var(--win-bg); color: var(--win-fg);
  border: 0.5px solid var(--win-border-inactive);
  border-radius: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .10), 0 10px 24px rgba(0, 0, 0, .12);
  pointer-events: auto;
  overflow: hidden;
}
.win.active {
  /* Win10"在标题栏和窗口边框上显示主题色"：活动窗口一圈清晰 accent 细边框 */
  border-color: var(--accent);
  box-shadow: 0 0 0 0.5px var(--accent),
    0 4px 10px rgba(0, 0, 0, .12), 0 14px 32px rgba(0, 0, 0, .20);
}
.win.maximized {
  left: 0 !important; top: 0 !important;
  width: 100% !important; height: 100% !important;
  border-radius: 0; border: none;
  box-shadow: none;
}
.win.minimized { display: none; }

/* 打开/关闭动画：轻微缩放与透明度过渡 */
@keyframes win-open {
  from { transform: scale(0.98); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes win-close {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(0.98); opacity: 0; }
}
.win.opening { animation: win-open .16s cubic-bezier(0.1, 0.9, 0.2, 1); }
.win.closing { animation: win-close .12s cubic-bezier(0.9, 0.1, 1, 0.2) forwards; pointer-events: none; }
.win-titlebar {
  height: var(--titlebar-h, 32px); flex: none;
  display: flex; align-items: center;
  padding-left: 8px; gap: 6px;
  touch-action: none;
  /* 标题栏纯色：亮色纯白、深色纯黑 */
  background: #FFFFFF;
}
[data-theme="dark"] .win-titlebar { background: #000000; }
.win-icon { display: inline-flex; opacity: .9; }
.win-title {
  flex: 1; font-size: 12px; font-weight: 400;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.win:not(.active) .win-title { opacity: .55; }
.win:not(.active) .win-icon { opacity: .5; }
.win-btns { display: flex; align-self: stretch; }
.win-btn {
  width: 46px; height: var(--titlebar-h, 32px); display: flex; align-items: center; justify-content: center;
  color: inherit; border-radius: 0;
}
.win-btn:hover { background: var(--titlebar-hover); }
.win-close:hover { background: var(--error); color: #fff; }
.win-body { flex: 1; overflow: auto; position: relative; background: var(--win-bg); }
.app-content { width: 100%; height: 100%; }

/* 手柄位于边框内侧，避免被窗口 overflow 裁剪 */
.win-rs { position: absolute; z-index: 5; touch-action: none; }
.win.maximized .win-rs { display: none; }
.rs-n  { top: 0; left: 10px; right: 10px; height: 7px; cursor: ns-resize; }
.rs-s  { bottom: 0; left: 10px; right: 10px; height: 7px; cursor: ns-resize; }
.rs-e  { right: 0; top: 10px; bottom: 10px; width: 7px; cursor: ew-resize; }
.rs-w  { left: 0; top: 10px; bottom: 10px; width: 7px; cursor: ew-resize; }
.rs-ne { right: 0; top: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.rs-sw { left: 0; bottom: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.rs-nw { left: 0; top: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.rs-se { right: 0; bottom: 0; width: 12px; height: 12px; cursor: nwse-resize; }
/* 触摸设备：放大内侧缩放热区 */
@media (pointer: coarse) {
  .rs-n  { left: 22px; right: 22px; height: 12px; }
  .rs-s  { left: 22px; right: 22px; height: 12px; }
  .rs-e  { top: 22px; bottom: 22px; width: 12px; }
  .rs-w  { top: 22px; bottom: 22px; width: 12px; }
  .rs-ne, .rs-se, .rs-nw, .rs-sw { width: 22px; height: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .win.opening, .win.closing { animation: none; }
  .win.closing { opacity: 0; }
  #snap-preview { transition: none !important; }
}

#snap-preview {
  position: fixed; z-index: 90; display: none;
  background: rgba(var(--accent-rgb), .22);
  border: 2px solid var(--accent);
  border-radius: 2px;
  pointer-events: none;
  transition: left .12s, top .12s, width .12s, height .12s;
}
#snap-preview.show { display: block; }
