/* ---------- Windows layer ---------- */
.windows { position: fixed; inset: 0 0 var(--taskbar-h) 0; pointer-events: none; z-index: 100; }
.windows > * { pointer-events: auto; }

/* ---------- Window ---------- */
.win {
  position: absolute; display: flex; flex-direction: column;
  background: var(--surface-solid); border: 1px solid var(--border-strong);
  border-radius: var(--radius-win); box-shadow: var(--shadow-win);
  overflow: hidden; min-width: 320px; min-height: 200px;
  animation: winIn .18s cubic-bezier(.2,.9,.3,1.1);
  will-change: transform, opacity;
}
body.no-transparency .win { background: var(--surface-solid); }
body:not(.no-transparency) .win { background: rgba(32,32,32,.92); backdrop-filter: blur(28px) saturate(150%); }
body.light:not(.no-transparency) .win { background: rgba(243,243,243,.92); }

@keyframes winIn { from { opacity: 0; transform: scale(.94) translateY(12px); } }
.win.closing { animation: winOut .16s ease forwards; }
@keyframes winOut { to { opacity: 0; transform: scale(.95); } }
.win.minimizing { animation: winMin .22s ease forwards; }
@keyframes winMin { to { opacity: 0; transform: scale(.75) translateY(220px); } }
.win.restoring { animation: winRestore .24s cubic-bezier(.2,.9,.3,1.15); }
@keyframes winRestore { from { opacity: 0; transform: scale(.82) translateY(160px); } }
.win.snapping { transition: left .18s ease, top .18s ease, width .18s ease, height .18s ease; }
.win.maximized { border-radius: 0; box-shadow: none; border-width: 0; }
.win.dragging, .win.resizing { transition: none; }
.win.dragging { cursor: move; }
.win.inactive .w-titlebar { opacity: .82; }
.win.inactive { box-shadow: 0 18px 44px rgba(0,0,0,.4); }

.w-titlebar {
  height: 40px; flex: none; display: flex; align-items: center; gap: 10px;
  padding-left: 14px; background: transparent; cursor: default;
}
.w-maximized .w-titlebar { }
.w-ico { width: 18px; height: 18px; display: grid; place-items: center; flex: none; }
.w-ico svg, .w-ico img { width: 18px; height: 18px; }
.w-title { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.w-controls { display: flex; height: 100%; margin-left: auto; }
.w-btn {
  width: 46px; height: 100%; display: grid; place-items: center; color: var(--text-2); transition: background .1s;
}
.w-btn:hover { background: var(--hover); color: var(--text); }
.w-btn.close:hover { background: #c42b1c; color: #fff; }
.w-btn svg { width: 10px; height: 10px; pointer-events: none; }
.w-content { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; overflow: hidden; }

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

.w-snap-hint {
  position: fixed; z-index: 4500; display: flex; gap: 8px; pointer-events: none;
}
.w-snap-hint .hint {
  background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.3); border-radius: 8px;
  color: #fff; font-size: 12px; padding: 8px 12px; backdrop-filter: blur(10px);
}

/* ---------- Generic app chrome ---------- */
.app { display: flex; flex-direction: column; height: 100%; min-height: 0; background: transparent; color: var(--text); }
.app-toolbar {
  flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  border-bottom: 1px solid var(--border); min-height: 46px;
}
.app-body { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.tb-ic {
  width: 32px; height: 32px; border-radius: var(--radius-sm); display: grid; place-items: center;
  color: var(--text-2); flex: none;
}
.tb-ic:hover { background: var(--hover); color: var(--text); }
.tb-ic:disabled { opacity: .35; pointer-events: none; }
.tb-ic svg { width: 16px; height: 16px; }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex: none; }
.btn {
  padding: 6px 14px; border-radius: var(--radius); background: var(--control); border: 1px solid var(--border);
  color: var(--text); font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--control-hover); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger:hover { background: #c42b1c; color: #fff; border-color: transparent; }
.field {
  background: var(--control); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 7px 10px; outline: none; color: var(--text); width: 100%;
}
.field:focus { border-color: var(--accent); }
.field::placeholder { color: var(--text-3); }
.hint { color: var(--text-3); font-size: 12px; }
.tabs { display: flex; gap: 4px; align-items: flex-end; flex: 1; min-width: 0; overflow: hidden; }
.tab {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 6px 6px 0 0;
  background: transparent; font-size: 12px; min-width: 0; max-width: 200px; border: 1px solid transparent;
  border-bottom: 0;
}
.tab.active { background: var(--surface-2); border-color: var(--border); }
.tab .tt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab .tx { width: 16px; height: 16px; border-radius: 3px; display: grid; place-items: center; font-size: 11px; }
.tab .tx:hover { background: var(--hover); }
