.window-surface {
  position: relative;
  transition: filter 120ms ease;
}

.window-surface:not(.is-focused) .title-bar,
.window-surface:not(.is-focused) .app-title-bar {
  filter: saturate(.48) brightness(1.08);
}

.app-window {
  position: fixed;
  left: max(128px, calc(50vw - 500px));
  top: 52px;
  width: min(1000px, calc(100vw - 170px));
  height: min(710px, calc(100vh - 105px));
  min-width: 560px;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: both;
  border: 3px solid #083fa5;
  border-radius: 8px 8px 2px 2px;
  background: #050705;
  box-shadow: 10px 15px 35px #001b3ea8;
}

.app-window.is-closed,
.app-window.is-minimized,
.task-button.is-closed,
.explorer-window.is-minimized {
  display: none;
}

.app-window.is-maximized {
  inset: 0 0 40px 0 !important;
  width: 100vw !important;
  height: calc(100vh - 40px) !important;
  max-width: none;
  max-height: none;
  border-radius: 0;
  resize: none;
}

.app-window:fullscreen,
.app-window.is-fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  resize: none;
}

.app-window.fullscreen-unavailable {
  animation: fullscreen-denied 180ms linear 3;
}

@keyframes fullscreen-denied {
  50% { filter: brightness(1.5); }
}

.app-title-bar {
  height: 33px;
  flex: 0 0 33px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 4px 7px;
  color: #fff;
  background: linear-gradient(#48a2ff 0, #1c67de 12%, #0754cf 72%, #003ca9);
  font: bold 13px Tahoma, sans-serif;
  text-shadow: 1px 1px #003184;
  user-select: none;
  cursor: default;
  touch-action: none;
}

.app-window.is-dragging .app-title-bar {
  cursor: grabbing;
}

.app-mark,
.task-bm {
  display: inline-grid;
  place-items: center;
  background: #10130d;
  color: #dcea6e;
  border: 1px solid #bcbcbc;
  font: bold 10px monospace;
  text-shadow: none;
}

.app-mark {
  width: 20px;
  height: 20px;
}

.task-bm {
  width: 17px;
  height: 17px;
}

.app-window-controls {
  display: flex;
  gap: 3px;
}

.app-window-controls button {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0 0 2px;
  border: 1px solid #fff;
  border-radius: 3px;
  color: #fff;
  background: linear-gradient(135deg, #78aaff, #0b55d3);
  box-shadow: inset 1px 1px #b9d4ff;
  font: bold 15px Arial, sans-serif;
  text-shadow: 1px 1px #17469c;
  cursor: pointer;
}

.app-window-controls button:hover {
  filter: brightness(1.15);
}

.app-window-controls button:last-child {
  background: linear-gradient(135deg, #ff9478, #d33215);
}

.app-frame-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #12377d;
  background: #050705;
}

.app-frame-shell iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #050705;
  opacity: 0;
  transition: opacity 220ms ease;
}

.app-window.is-loaded iframe {
  opacity: 1;
}

.app-loading {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #aab88a;
  background: radial-gradient(circle at center, #182016, #050705 60%);
  font: 11px Tahoma, sans-serif;
  letter-spacing: .08em;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.app-window.is-loaded .app-loading {
  opacity: 0;
  visibility: hidden;
}

.app-loading-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 4px solid #777;
  background: #0d110a;
  color: #dcea6e;
  box-shadow: inset 0 0 0 4px #252b20, 0 8px 25px #000;
  font: bold 25px monospace;
}

.app-loading i {
  width: 170px;
  height: 11px;
  overflow: hidden;
  border: 1px solid #53604a;
  background: #020302;
}

.app-loading i::after {
  content: '';
  display: block;
  width: 34%;
  height: 100%;
  background: #b5ce62;
  animation: app-load 900ms ease-in-out infinite alternate;
}

@keyframes app-load {
  from { transform: translateX(-100%); }
  to { transform: translateX(300%); }
}

.task-button {
  justify-content: flex-start;
  flex: 0 1 210px;
  min-width: 105px;
  cursor: pointer;
  font-family: Tahoma, sans-serif;
  text-align: left;
}

.task-button.is-active {
  background: #1852b7;
  box-shadow: inset 1px 2px 4px #0d347e;
}

.bareminimum-task {
  animation: task-arrive 240ms ease-out both;
}

@keyframes task-arrive {
  from { max-width: 0; opacity: 0; transform: translateX(-8px); }
  to { max-width: 210px; opacity: 1; transform: translateX(0); }
}

@media (max-width: 900px) {
  .app-window {
    left: 4vw;
    top: 4vh;
    width: 92vw;
    height: calc(96vh - 44px);
    min-width: 0;
    min-height: 300px;
  }
}

@media (max-width: 620px) {
  .app-window.is-maximized {
    bottom: 36px !important;
    height: calc(100vh - 36px) !important;
  }

  .task-button {
    flex-basis: 104px;
    width: auto;
    padding: 0 6px;
  }

  .system-tray {
    min-width: 57px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-loading i::after,
  .bareminimum-task {
    animation: none;
  }
}
