/* Windows. */

.wm {
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.win {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: var(--radius-window);
  background: var(--surface-1);
  box-shadow: 0 16px 44px -18px rgba(6, 7, 3, 0.75), 0 0 0 1px var(--rule-2);
  animation: win-in var(--dur-2) var(--ease-out);
}
@keyframes win-in {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
}
.win.is-focused {
  box-shadow: var(--elev-window), 0 0 0 1px var(--rule-3);
}
.win.is-max {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: var(--radius-window) var(--radius-window) 0 0;
  box-shadow: 0 0 0 1px var(--rule-1);
}
/* Minimized windows stay laid out (terminals keep their size and state), just invisible. */
.win.is-min {
  visibility: hidden;
  pointer-events: none;
  animation: none;
}
.win.is-closing {
  opacity: 0;
  transform: scale(0.985);
  transition: opacity var(--dur-2), transform var(--dur-2);
  pointer-events: none;
}

.win-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 36px;
  padding: 0 var(--sp-1h) 0 var(--sp-3);
  border-radius: var(--radius-window) var(--radius-window) 0 0;
  background: var(--surface-0);
  color: var(--ink-3);
  cursor: default;
  user-select: none;
  touch-action: none;
}
.win.is-focused .win-bar {
  color: var(--ink-2);
}
.win-icon {
  display: grid;
  color: var(--ink-4);
}
.win.is-focused .win-icon {
  color: var(--ink-3);
}
.win-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-meta);
  font-weight: var(--fw-medium);
}
.win.is-focused .win-title {
  color: var(--ink-1);
}
.win-badge {
  flex: none;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font: var(--fw-medium) var(--fs-micro) / 18px var(--sans);
}
.win-actions {
  flex: none;
  display: flex;
  gap: 2px;
}
.win-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 24px;
  border: 0;
  border-radius: var(--radius-inner);
  background: none;
  color: var(--ink-4);
  cursor: pointer;
  transition: background var(--dur-1), color var(--dur-1);
}
.win-btn:hover {
  background: var(--surface-2);
  color: var(--ink-1);
}
.win-close:hover {
  background: var(--danger);
  color: #2a0807;
}
.win.is-focused .win-btn {
  color: var(--ink-3);
}

.win-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: 0 0 var(--radius-window) var(--radius-window);
  outline: none;
}
.win.is-max .win-body {
  border-radius: 0;
}

/* Case windows: the case tabs are the title bar (src/apps/case/tabs.ts moves them in). */
.win[data-app="case"] .win-bar {
  height: 42px;
  padding-left: var(--sp-2);
  align-items: stretch;
}
.win[data-app="case"] .win-bar > .win-icon,
.win[data-app="case"] .win-bar > .win-title,
.win[data-app="case"] .win-bar > .win-badge {
  display: none;
}
.win[data-app="case"] .win-bar > .win-actions {
  align-self: center;
}

.win-grip {
  position: absolute;
  z-index: 2;
  touch-action: none;
}
.win-grip[data-edge="n"] {
  top: -4px;
  left: 8px;
  right: 8px;
  height: 8px;
  cursor: ns-resize;
}
.win-grip[data-edge="s"] {
  bottom: -4px;
  left: 8px;
  right: 8px;
  height: 8px;
  cursor: ns-resize;
}
.win-grip[data-edge="e"] {
  right: -4px;
  top: 8px;
  bottom: 8px;
  width: 8px;
  cursor: ew-resize;
}
.win-grip[data-edge="w"] {
  left: -4px;
  top: 8px;
  bottom: 8px;
  width: 8px;
  cursor: ew-resize;
}
.win-grip[data-edge="ne"],
.win-grip[data-edge="nw"],
.win-grip[data-edge="se"],
.win-grip[data-edge="sw"] {
  width: 14px;
  height: 14px;
}
.win-grip[data-edge="ne"] {
  top: -5px;
  right: -5px;
  cursor: nesw-resize;
}
.win-grip[data-edge="sw"] {
  bottom: -5px;
  left: -5px;
  cursor: nesw-resize;
}
.win-grip[data-edge="nw"] {
  top: -5px;
  left: -5px;
  cursor: nwse-resize;
}
.win-grip[data-edge="se"] {
  bottom: -5px;
  right: -5px;
  cursor: nwse-resize;
}
.win.is-max .win-grip {
  display: none;
}

.snap-preview {
  position: absolute;
  border: 1px solid var(--acc);
  border-radius: var(--r-lg);
  background: rgba(217, 191, 134, 0.06);
  box-shadow: inset 0 0 40px rgba(217, 191, 134, 0.06);
  pointer-events: none;
  transition: all 0.12s var(--ease);
}

.app-error {
  margin: 16px;
  padding: 10px 12px;
  border: 1px solid var(--danger-line);
  border-radius: var(--r);
  background: rgba(255, 91, 87, 0.05);
  color: var(--red);
  font: 12px var(--sans);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
