/* Window chrome, animations, snap layouts, Task View, Alt+Tab, dialogs, and shared controls */
.windows {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--canvas);
  border-radius: var(--radius);
  box-shadow: var(--shadow-window);
  overflow: hidden;
  pointer-events: auto;
  transform-origin: center bottom;
}

.window.is-max {
  border-radius: 0;
}

.window.inactive {
  box-shadow: var(--shadow-inactive);
}

.window.inactive .titlebar-title {
  color: var(--text-3);
}

.window.dragging {
  transition: none;
}

.window.animating {
  transition: left 0.22s var(--ease), top 0.22s var(--ease), width 0.22s var(--ease), height 0.22s var(--ease);
}

.window.is-minimized {
  display: none;
}

.window.opening {
  animation: win-open 0.2s var(--ease-out);
}

.window.closing {
  animation: win-close 0.16s var(--ease-out) forwards;
  pointer-events: none;
}

.window.minimizing {
  animation: win-min 0.2s var(--ease-out) forwards;
  pointer-events: none;
}

.window.restoring {
  animation: win-restore 0.2s var(--ease-out);
}

@keyframes win-open {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes win-close {
  to {
    opacity: 0;
    transform: scale(0.96);
  }
}

@keyframes win-min {
  to {
    opacity: 0;
    transform: scale(0.5) translateY(60px);
  }
}

@keyframes win-restore {
  from {
    opacity: 0;
    transform: scale(0.5) translateY(60px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.titlebar {
  flex: 0 0 32px;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
  background: var(--titlebar);
  cursor: default;
  touch-action: none;
}

[data-accent-titles="on"] .window:not(.inactive) .titlebar {
  background: var(--accent);
  color: #fff;
}

[data-accent-titles="on"] .window:not(.inactive) .cap-btn {
  color: #fff;
}

.titlebar-icon {
  display: flex;
  color: var(--accent);
}

.titlebar-icon .ico {
  width: 16px;
  height: 16px;
}

.titlebar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.caps {
  display: flex;
  height: 100%;
}

.cap-btn {
  width: 46px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

.cap-ico {
  width: 11px;
  height: 11px;
  stroke-width: 1.3;
}

.cap-btn:hover {
  background: var(--subtle);
}

.cap-close:hover {
  background: #c42b1c;
  color: #fff;
}

.window-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--canvas);
}

/* Resize handles sit inside the window edges so overflow:hidden does not clip them */
.rz {
  position: absolute;
  z-index: 3;
}

.rz-n,
.rz-s {
  left: 10px;
  right: 10px;
  height: 5px;
  cursor: ns-resize;
}

.rz-n {
  top: 0;
}

.rz-s {
  bottom: 0;
}

.rz-e,
.rz-w {
  top: 10px;
  bottom: 10px;
  width: 5px;
  cursor: ew-resize;
}

.rz-e {
  right: 0;
}

.rz-w {
  left: 0;
}

.rz-ne,
.rz-nw,
.rz-se,
.rz-sw {
  width: 12px;
  height: 12px;
}

.rz-ne {
  top: 0;
  right: 0;
  cursor: nesw-resize;
}

.rz-sw {
  bottom: 0;
  left: 0;
  cursor: nesw-resize;
}

.rz-nw {
  top: 0;
  left: 0;
  cursor: nwse-resize;
}

.rz-se {
  bottom: 0;
  right: 0;
  cursor: nwse-resize;
}

.window.is-max .rz {
  display: none;
}

.snap-preview {
  position: fixed;
  z-index: 1100;
  background: rgba(var(--accent-rgb), 0.2);
  border: 2px solid rgba(var(--accent-rgb), 0.9);
  border-radius: var(--radius);
  pointer-events: none;
  transition: all 0.12s var(--ease-out);
}

/* Snap layouts: appears under the maximize button */
.snap-layouts {
  position: fixed;
  z-index: 1100;
  display: flex;
  gap: 8px;
  padding: 10px;
  background: var(--flyout);
  border-radius: var(--radius);
  box-shadow: var(--shadow-flyout);
}

.snap-layout {
  width: 96px;
  height: 60px;
  padding: 4px;
  border-radius: 4px;
  background: var(--subtle);
}

.snap-layout:hover {
  background: var(--subtle-press);
}

.snap-layout svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.snap-zone {
  fill: rgba(var(--accent-rgb), 0.35);
  stroke: var(--stroke-strong);
  stroke-width: 1;
  cursor: pointer;
}

.snap-zone:hover {
  fill: rgba(var(--accent-rgb), 0.75);
}

/* Task View */
.taskview {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  animation: fade-in 0.18s var(--ease-out);
}

.tv-inner {
  position: absolute;
  inset: 0 0 calc(var(--taskbar-h) + 20px) 0;
  padding: 48px 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: auto;
}

.tv-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  max-width: 1200px;
}

.tv-card {
  width: 300px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--flyout);
  box-shadow: var(--shadow-flyout);
  cursor: default;
  transition: transform 0.15s var(--ease);
}

.tv-card:hover {
  transform: scale(1.02);
}

.tv-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 8px;
}

.tv-ico .ico {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.tv-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
}

.tv-thumb {
  height: 170px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 25%, var(--canvas)), var(--canvas));
  border: 1px solid var(--stroke);
}

.tv-thumb.minimized {
  opacity: 0.6;
}

.tv-big .ico {
  width: 64px;
  height: 64px;
  color: var(--accent);
  stroke-width: 1.2;
}

.tv-hint,
.tv-empty {
  margin-top: 28px;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  font-size: 13px;
}

.tv-empty {
  color: #fff;
}

/* Alt+Tab switcher */
.alttab {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1250;
  padding: 14px;
  max-width: calc(100vw - 40px);
  background: var(--flyout);
  border-radius: 14px;
  box-shadow: var(--shadow-flyout);
  animation: fade-in 0.12s var(--ease-out);
}

[data-transparency="on"] .alttab {
  backdrop-filter: blur(40px) saturate(1.6);
}

.alttab-strip {
  display: flex;
  gap: 8px;
  overflow: hidden;
}

.alttab-tile {
  width: 120px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius);
  border: 2px solid transparent;
}

.alttab-tile.selected {
  background: var(--subtle);
  border-color: var(--accent);
}

.alttab-ico .ico {
  width: 36px;
  height: 36px;
  color: var(--accent);
}

.alttab-title {
  font-size: 12px;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Dialogs */
.dialog-layer {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.3);
  animation: fade-in 0.15s var(--ease-out);
}

.dialog {
  max-width: calc(100vw - 32px);
  padding: 24px;
  background: var(--layer);
  border-radius: 8px;
  box-shadow: var(--shadow-flyout);
  animation: win-open 0.18s var(--ease-out);
}

.dialog-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dialog-icon .ico {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.dialog-title {
  font: 600 20px/1.2 var(--font-display);
}

.dialog-body {
  margin-top: 12px;
}

.dialog-message {
  margin: 0 0 4px;
  color: var(--text-2);
  line-height: 1.5;
}

.dialog-label {
  display: block;
  margin: 8px 0 6px;
  font-size: 13px;
}

.dialog-input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--stroke-strong);
  border-bottom-color: var(--text-2);
  border-radius: var(--radius-sm);
  background: var(--card);
  outline: none;
}

.dialog-input:focus {
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.props {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 320px;
}

.props-row {
  display: flex;
  gap: 16px;
}

.props-k {
  width: 90px;
  color: var(--text-2);
}

.props-v {
  flex: 1;
  word-break: break-all;
}

/* Shared controls */
.btn {
  min-width: 80px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--stroke-strong);
  border-bottom-color: color-mix(in srgb, var(--text) 30%, transparent);
  border-radius: var(--radius-sm);
  background: var(--control);
  cursor: default;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--control-hover);
}

.btn:active:not(:disabled) {
  background: var(--control-press);
}

.btn:disabled {
  opacity: 0.5;
}

.btn-sm {
  min-width: 0;
  height: 28px;
  padding: 0 12px;
}

.btn-accent {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-text);
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-accent:active:not(:disabled) {
  background: var(--accent-press);
}

.btn-danger {
  border-color: transparent;
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: default;
}

.icon-btn.small {
  width: 28px;
  height: 28px;
}

.icon-btn:hover:not(:disabled) {
  background: var(--subtle);
}

.icon-btn:disabled {
  opacity: 0.35;
}

.icon-btn.on {
  background: var(--subtle-press);
}

.switch {
  position: relative;
  width: 40px;
  height: 20px;
  flex: none;
  padding: 0;
  border: 1px solid var(--stroke-strong);
  border-radius: 10px;
  background: var(--control);
  cursor: default;
  transition: background 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}

.switch-knob {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform 0.18s var(--ease), background 0.15s;
}

.switch.on {
  background: var(--accent);
  border-color: var(--accent);
}

.switch.on .switch-knob {
  transform: translateX(20px);
  background: var(--accent-text);
}

.switch:disabled {
  opacity: 0.4;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 180px;
  height: 20px;
  background: transparent;
  cursor: default;
  --fill: 50%;
}

.slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--stroke-strong) var(--fill));
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--stroke-strong);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--stroke-strong);
}

.slider::-moz-range-progress {
  height: 4px;
  background: var(--accent);
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--stroke-strong);
}
