.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(0, 0, 0, 0.55);
  overflow: visible;
  color: #1c1914;
  background: #c8c4bb;
}

.titlebar {
  touch-action: none;
  height: 28px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px 0 8px;
  cursor: grab;
  color: #f4f1ea;
  background: linear-gradient(180deg, #4e5663 0%, #2c323b 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 3px 3px 0 0;
  user-select: none;
}

.window.focused .titlebar {
  background: linear-gradient(180deg, #6d5834 0%, #3c3124 58%, #2a241c 100%);
}

body.matrix-mode .window .titlebar {
  background: linear-gradient(180deg, #1c3a28, #0e1c14);
}

body.matrix-mode .window.focused .titlebar {
  background: linear-gradient(180deg, #1f6a38, #0c2416 60%, #08140e);
}

.title-icon { width: 14px; height: 14px; display: inline-flex; flex: none; }
.title-icon svg { width: 14px; height: 14px; display: block; }
.title-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.window:not(.focused) .title-text { color: #c8c2b6; }

.tb {
  width: 18px;
  height: 16px;
  padding: 0;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.55);
  background: linear-gradient(180deg, #8b939e, #4e565f);
  color: #fff;
  line-height: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  cursor: pointer;
}

.tb.close:hover, .tb.close:focus-visible {
  background: linear-gradient(180deg, #e06a5c, #9c2e24);
}

.window-body {
  position: absolute;
  left: 0;
  right: 0;
  top: 28px;
  bottom: 0;
  overflow: hidden;
  background: #d7d4cc;
  border-radius: 0 0 3px 3px;
}

.handle { position: absolute; z-index: 3; touch-action: none; }
.handle.n, .handle.s { left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.handle.n { top: -3px; }
.handle.s { bottom: -3px; }
.handle.e, .handle.w { top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.handle.e { right: -3px; }
.handle.w { left: -3px; }
.handle.nw, .handle.ne, .handle.sw, .handle.se { width: 10px; height: 10px; }
.handle.nw { top: -3px; left: -3px; cursor: nwse-resize; }
.handle.se { bottom: -3px; right: -3px; cursor: nwse-resize; }
.handle.ne { top: -3px; right: -3px; cursor: nesw-resize; }
.handle.sw { bottom: -3px; left: -3px; cursor: nesw-resize; }
.window.max .handle { display: none; }

.window.minimized { display: none; }
.window.shaded .window-body, .window.shaded .handle { display:none; }
.window.shaded { min-height:28px; }
.burn-edge { position:absolute; z-index:8; left:-4px; right:-4px; height:22px; pointer-events:none; background:linear-gradient(0deg,transparent,#e7480b 32%,#ffc326 65%,#fff4b0 82%,transparent); box-shadow:0 0 18px #ff7400; }
.window-effects { border-top:1px solid #5a6670; margin-top:5px; padding:6px 8px; }
.window-effects label { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:4px 0; }
.window-effects select { max-width:185px; background:#172531; color:#fff; border:1px solid #627687; padding:3px; }
.burn-edge::before { content:''; position:absolute; inset:-13px 0 5px; background:linear-gradient(0deg,#fff5ba,#ffb400 42%,#f64205 72%,transparent); clip-path:polygon(0 100%,0 65%,3% 30%,5% 70%,8% 15%,12% 80%,17% 20%,22% 65%,28% 5%,35% 75%,41% 25%,48% 80%,54% 10%,62% 65%,69% 20%,75% 75%,83% 10%,90% 70%,97% 25%,100% 70%,100% 100%); animation:burn-flicker .09s steps(2) infinite alternate; }
@keyframes burn-flicker { to { transform:scaleY(.72); opacity:.7; } }
@media (prefers-reduced-motion:reduce) { .burn-edge::before { animation:none; } }
body[data-ui-theme] .window .titlebar { background:linear-gradient(#ffffff22,transparent),var(--chrome-bg); color:var(--chrome-ink); border-color:var(--chrome-edge); }
body[data-ui-theme] .window.focused .titlebar { background:linear-gradient(#ffffff22,transparent),var(--chrome-active); }
body.matrix-mode .window .titlebar { background:linear-gradient(#1c3a28,#0e1c14); color:#d8ffe4; }
body.matrix-mode .window.focused .titlebar { background:linear-gradient(#1f6a38,#0c2416); }
body[data-ui-theme="starship"] .window-body { border-radius:0 0 5px 5px; }
.burn-edge { height:28px; background:linear-gradient(0deg,#b82b05,#ff670a 35%,#ffca39 65%,#fff4bd 85%,transparent); box-shadow:0 0 22px 5px #ff7400aa; }
.burn-edge::before { inset:-22px 0 8px; filter:drop-shadow(0 -3px 5px #ff8c00); }
