/* ============================================================
   Window system (6.5 / 6.6) — hard pixel edges, no rounded corners
   ============================================================ */
.windows-layer { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.win {
  position: absolute; display: flex; flex-direction: column;
  min-width: 260px; min-height: 160px;
  background: var(--win-bg); color: var(--text);
  border: 2px solid var(--border);
  box-shadow: var(--bevel), var(--drop);
  pointer-events: auto;
  animation: win-pop .16s steps(4) both;
}
@keyframes win-pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.win.closing { animation: win-close .14s steps(3) forwards; }
@keyframes win-close { to { transform: scale(.85); opacity: 0; } }
.win.minimizing { animation: win-min .2s steps(4) forwards; }
@keyframes win-min { to { transform: translateY(60%) scale(.2); opacity: 0; } }
.win.maximized { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; box-shadow: none; }
.win.snapping { transition: left .12s steps(3), top .12s steps(3), width .12s steps(3), height .12s steps(3); }

.win-title {
  flex: none; display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 4px 0 6px;
  background: var(--title-inactive); border-bottom: 2px solid var(--border);
  font-family: var(--font-pixel); font-size: 14px; user-select: none; touch-action: none; cursor: grab;
}
.win.active .win-title {
  background:
    repeating-linear-gradient(to bottom, transparent 0 3px, rgba(255, 255, 255, .28) 3px 5px) right 96px center / 30% 14px no-repeat,
    var(--title-active);
}
.win-title img { width: 18px; height: 18px; }
.win-title .t { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.win-btns { display: flex; gap: 3px; }
.wbtn {
  width: 24px; height: 22px; padding: 0; position: relative;
  background: var(--face); border: 2px solid var(--border); box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 var(--shadow);
  cursor: pointer;
}
.wbtn:active { box-shadow: inset 1px 1px 0 var(--shadow); }
.wbtn::before, .wbtn::after { content: ""; position: absolute; background: var(--text); }
.wbtn.min::before { left: 5px; right: 5px; bottom: 4px; height: 3px; }
.wbtn.max::before { left: 4px; right: 4px; top: 3px; bottom: 3px; background: none; border: 2px solid var(--text); border-top-width: 3px; }
.wbtn.close::before, .wbtn.close::after { left: 9px; top: 3px; width: 3px; height: 13px; }
.wbtn.close::before { transform: rotate(45deg); }
.wbtn.close::after { transform: rotate(-45deg); }
.wbtn.close:hover { background: var(--pink); }

.win-body { position: relative; flex: 1; overflow: auto; overscroll-behavior: contain; }
.win-status {
  flex: none; display: flex; align-items: center; gap: 12px; min-height: 24px; padding: 2px 8px;
  border-top: 2px solid var(--border); background: var(--face);
  font-family: var(--font-mono); font-size: 11px; color: var(--text-2);
}
.win-status .grow { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.win-status button { font-family: var(--font-mono); font-size: 11px; background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; text-decoration: underline; }
.win-resize {
  position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; touch-action: none;
  background:
    linear-gradient(135deg, transparent 0 55%, var(--text-2) 55% 62%, transparent 62% 72%, var(--text-2) 72% 79%, transparent 79%);
}
.win.maximized .win-resize, .win.no-resize .win-resize { display: none; }

/* Modal dialogs (confirm Restart / Shut Down) */
.modal-backdrop { position: fixed; inset: 0; z-index: 7000; background: rgba(25, 23, 45, .35); display: grid; place-items: center; }
.modal-backdrop .win { position: relative; width: min(400px, 92vw); min-height: 0; animation: win-pop .16s steps(4) both; }
.dialog-body { display: flex; gap: 14px; padding: 18px; font-size: 15px; line-height: 1.5; }
.dialog-body img { width: 48px; height: 48px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 16px; }

/* Handheld: every app is a full-screen retro window */
.screen.handheld .windows-layer { position: fixed; top: var(--menubar-h); bottom: var(--taskbar-h); left: 0; right: 0; z-index: 2600; }
.screen.handheld .win { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; box-shadow: none; }
.screen.handheld .win-title { height: 36px; cursor: default; }
.screen.handheld .wbtn { width: 32px; height: 28px; }
.screen.handheld .wbtn.close::before, .screen.handheld .wbtn.close::after { left: 12px; top: 5px; height: 15px; }
.screen.handheld .wbtn.max, .screen.handheld .win-resize { display: none; }
