/* ============ 窗口 ============ */
#windows { position: absolute; inset: 0; z-index: 2; pointer-events: none; }

.win { position: absolute; pointer-events: auto; border-radius: 18px; }
.win.is-min { display: none; }
.win.closing { pointer-events: none; }
.win.animating { transition: left .34s var(--ease-out), top .34s var(--ease-out), width .34s var(--ease-out), height .34s var(--ease-out); }

.win-frame {
  position: absolute; inset: 0; border-radius: inherit; overflow: hidden;
  background: var(--surface);
  -webkit-backdrop-filter: blur(40px) saturate(190%);
  backdrop-filter: blur(40px) saturate(190%);
  box-shadow: 0 0 0 .5px rgba(0, 0, 0, .22), 0 30px 70px -8px rgba(0, 0, 0, .42), 0 8px 20px rgba(0, 0, 0, .14), inset 0 0 0 .5px var(--win-edge);
  transition: box-shadow .25s;
}
.win:not(.active) .win-frame { box-shadow: 0 0 0 .5px rgba(0, 0, 0, .16), 0 16px 40px -10px rgba(0, 0, 0, .3), inset 0 0 0 .5px var(--win-edge); }

.win-body { position: absolute; inset: 0; display: flex; overflow: hidden; }

.win-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  height: var(--bar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px 0 14px;
}
.win.dragging .win-bar { cursor: grabbing; }

/* 红绿灯（macOS） */
.win-ctrl { display: flex; gap: 8px; padding: 0 0 0 6px; }
.wc {
  position: relative; width: 12px; height: 12px; border-radius: 50%;
  display: grid; place-items: center; color: rgba(0, 0, 0, .55);
  box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .14);
}
.wc .glyph { width: 8px; height: 8px; stroke-width: 3.2; opacity: 0; }
.win-ctrl:hover .wc .glyph { opacity: 1; }
.wc:active { filter: brightness(.82); }
.wc-close { background: #ff5f57; }
.wc-min { background: #febc2e; }
.wc-max { background: #28c840; }
.win:not(.active) .wc { background: rgba(140, 140, 140, .28); }
[data-theme="dark"] .win:not(.active) .wc { background: rgba(255, 255, 255, .16); }
.win:not(.active) .win-ctrl:hover .wc-close { background: #ff5f57; }
.win:not(.active) .win-ctrl:hover .wc-min { background: #febc2e; }
.win:not(.active) .win-ctrl:hover .wc-max { background: #28c840; }

.win-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  max-width: 40%; pointer-events: none;
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.win:not(.active) .win-title { opacity: .45; }
.win-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.win-home { display: none; }

/* 拉伸手柄 */
.rz { position: absolute; z-index: 4; }
.rz-n { top: -4px; left: 14px; right: 14px; height: 8px; cursor: ns-resize; }
.rz-s { bottom: -4px; left: 14px; right: 14px; height: 8px; cursor: ns-resize; }
.rz-e { right: -4px; top: 14px; bottom: 14px; width: 8px; cursor: ew-resize; }
.rz-w { left: -4px; top: 14px; bottom: 14px; width: 8px; cursor: ew-resize; }
.rz-ne, .rz-nw, .rz-se, .rz-sw { width: 18px; height: 18px; }
.rz-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.rz-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.rz-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.rz-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.win.is-max .rz { display: none; }

/* ============ 手机：全屏 App ============ */
html.mobile { --bar-h: calc(var(--menubar-h) + 46px); }
html.mobile .win {
  position: fixed; left: 0 !important; top: 0 !important;
  width: 100% !important; height: 100% !important;
  z-index: 2400; border-radius: 0;
  will-change: transform;
}
html.mobile .win-frame {
  background: var(--surface-solid);
  -webkit-backdrop-filter: none; backdrop-filter: none;
  box-shadow: 0 0 40px rgba(0, 0, 0, .3);
}
html.mobile .win-ctrl, html.mobile .rz { display: none; }
html.mobile .win-bar {
  padding: var(--menubar-h) 14px 0;
  background: linear-gradient(var(--surface-solid) 70%, transparent);
}
html.mobile #windows { z-index: 2500; }
html.mobile .win-title {
  left: 20px; transform: none; top: calc(var(--menubar-h) + 4px);
  font-size: 28px; font-weight: 800; letter-spacing: .01em; color: var(--text); max-width: 50%;
}
html.mobile .win-tools .seg:has([data-view]) { display: none; }
html.mobile .win:not(.active) .win-title { opacity: 1; }
html.mobile .win-home {
  display: grid; place-items: center;
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  height: calc(28px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  touch-action: none;
}
html.mobile .win-home i { width: 134px; height: 5px; border-radius: 5px; background: var(--text); opacity: .85; }
