/* ==========================================================================
   窗口管理器样式
   发丝线边框 / 低扩散投影 / 44px 标题栏 / 聚焦时左侧强调刻度
   ========================================================================== */

.windows-layer {
  position: absolute;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 400px;
  min-height: 280px;
  pointer-events: auto;
  border-radius: var(--radius-lg);
  background: var(--mica);
  backdrop-filter: blur(38px) saturate(150%);
  -webkit-backdrop-filter: blur(38px) saturate(150%);
  border: 1px solid var(--stroke-outer);
  box-shadow: var(--shadow-win), inset 0 1px 0 rgba(255, 255, 255, .28);
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.955);
  transition: opacity .18s var(--ease), transform .26s cubic-bezier(.16, .84, .3, 1), box-shadow .2s var(--ease);
  will-change: transform;
}
html[data-theme="dark"] .window {
  border-color: rgba(255, 255, 255, .1);
  box-shadow: var(--shadow-win), inset 0 1px 0 rgba(255, 255, 255, .06);
}

.window.enter { opacity: 1; transform: translateY(0) scale(1); }
.window.leave { opacity: 0; transform: translateY(10px) scale(.975); }
.window.leaving-min { opacity: 0; transform: translateY(64px) scale(.9); }

/* 最大化 / 还原时补间矩形 */
.window.rect-anim {
  transition: left .26s var(--ease), top .26s var(--ease),
              width .26s var(--ease), height .26s var(--ease),
              border-radius .22s var(--ease);
}

/* 窗口内容入场 */
@keyframes winContentIn {
  from { opacity: 0; transform: translateY(8px); }
}
.win-body > * { animation: winContentIn .3s var(--ease) backwards; }

.window:not(.focused) { filter: saturate(.94); }
.window:not(.focused) .win-titlebar { opacity: .72; }
.window:not(.focused) .win-body { opacity: .96; }

/* 最大化 / 吸附 */
.window.maximized {
  border-radius: 0;
  border-color: transparent;
}
.window.snapped-left, .window.snapped-right { border-radius: 10px; }

/* ---------- 标题栏 ---------- */
.win-titlebar {
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 16px;
  padding-right: 4px;
  cursor: default;
  position: relative;
  background: var(--tile-2);
  border-bottom: 1px solid var(--stroke);
  transition: opacity .18s;
}

/* 聚焦刻度 */
.win-titlebar::before {
  content: "";
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
  opacity: 0;
  transform: scaleY(.6);
  transition: opacity .18s, transform .22s var(--ease);
}
.window.focused .win-titlebar::before { opacity: 1; transform: scaleY(1); }

.win-app {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; flex: 1;
  pointer-events: none;
}
.win-app .si { width: 16px; height: 16px; flex: none; }
.win-app .si svg { width: 16px; height: 16px; }
.win-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.win-controls { display: flex; align-items: center; gap: 0; }
.win-btn {
  width: 46px; height: 30px;
  border-radius: 0;
  display: grid; place-items: center;
  color: var(--text-2);
  transition: background .13s, color .13s;
}
.win-btn:hover { background: var(--hover); color: var(--text); }
.win-btn:active { background: var(--active); }
.win-btn.close:hover { background: #b6402f; color: #fff; }
.win-btn svg { width: 10px; height: 10px; stroke-width: 1.5; fill: none; stroke: currentColor; }

/* ---------- 窗口主体 ---------- */
.win-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--mica-strong);
  position: relative;
}
html[data-theme="light"] .win-body { background: #fbfaf6; }
html[data-theme="dark"] .win-body { background: #17181a; }

/* ---------- 缩放手柄 ---------- */
.win-resize { position: absolute; z-index: 5; }
.win-resize.e { top: 0; right: 0; width: 6px; height: 100%; cursor: ew-resize; }
.win-resize.s { bottom: 0; left: 0; width: 100%; height: 6px; cursor: ns-resize; }
.win-resize.w { top: 0; left: 0; width: 6px; height: 100%; cursor: ew-resize; }
.win-resize.n { top: 0; left: 0; width: 100%; height: 6px; cursor: ns-resize; }
.win-resize.se { right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; }
.win-resize.sw { left: 0; bottom: 0; width: 16px; height: 16px; cursor: nesw-resize; }
.win-resize.ne { right: 0; top: 0; width: 16px; height: 16px; cursor: nesw-resize; }
.win-resize.nw { left: 0; top: 0; width: 16px; height: 16px; cursor: nwse-resize; }

.window.maximized .win-resize { display: none; }

/* 拖拽时降低重绘开销 */
.window.dragging, .window.resizing {
  transition: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: var(--mica-strong);
}
.window.dragging .win-body, .window.resizing .win-body { background: var(--mica-strong); }

/* 吸附预览 */
.snap-preview {
  position: absolute;
  z-index: 90;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  pointer-events: none;
  transition: all .14s var(--ease);
}
