/*
 * Window Dock — its own small native window, sized to exactly what it shows.
 * Matte dark from the app's appearance tokens (light follows Settings),
 * 5px geometry, rectangular controls, hairline edges, no badges. What waits
 * for the person is the only warning-colored text. Reduced motion, reduced
 * transparency and forced colors keep every control and boundary.
 */

html,
body {
  margin: 0;
  background: var(--color-surface-abyss);
  overflow: hidden;
}

.wd-root {
  --wd-line: rgba(var(--accent-rgb), 0.14);
  --wd-line-strong: rgba(var(--accent-rgb), 0.42);
  --wd-hover: rgba(var(--surface-elevated-rgb), 0.9);
  --wd-wash: rgba(var(--accent-rgb), 0.1);
  --wd-radius: 5px;
  --wd-dur: 0.14s;
  /* Measured at its own natural size, never squeezed to the window's current
     size, so native can size the window to it. */
  position: absolute;
  top: 0;
  left: 0;
  width: max-content;
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 0;
  color: var(--color-text-primary);
  background: var(--color-surface-abyss);
  font-family: var(--font-sans, "Outfit", system-ui, sans-serif);
  font-size: 13px;
  line-height: 1.25;
  user-select: none;
}

.wd-root--empty {
  width: 1px;
  height: 1px;
}

.wd-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wd-tnum {
  font-variant-numeric: tabular-nums;
}

/* The Dock bar */
.wd-dock {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 4px 6px;
  background: var(--color-surface-abyss);
  border: 1px solid var(--wd-line);
  border-radius: var(--wd-radius);
  box-sizing: border-box;
  white-space: nowrap;
  animation: wd-in 0.18s ease-out;
}

.wd-root[data-noticed] .wd-dock {
  border-color: var(--wd-line-strong);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.28);
}

@keyframes wd-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.wd-label {
  padding: 0 4px;
  color: var(--color-text-secondary);
}

.wd-ask {
  color: var(--color-warning);
}

.wd-return,
.wd-back,
.wd-btn,
.wd-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  font: inherit;
  color: var(--color-text-primary);
  background: transparent;
  border: 1px solid var(--wd-line);
  border-radius: var(--wd-radius);
  cursor: pointer;
  transition:
    background var(--wd-dur) ease,
    border-color var(--wd-dur) ease;
}

.wd-return {
  border-color: var(--wd-line-strong);
}

.wd-return svg {
  transition: transform var(--wd-dur) ease;
}

.wd-return:hover svg {
  transform: translateX(2px);
}

.wd-btn--ghost {
  border-color: transparent;
}

.wd-return:hover,
.wd-back:hover,
.wd-btn:hover,
.wd-group:hover,
.wd-tool:hover,
.wd-tool[aria-expanded="true"] {
  background: var(--wd-hover);
}

.wd-group__title {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wd-group[data-tone="needs-you"] {
  border-color: rgba(251, 191, 36, 0.45);
}

.wd-page {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-left: 4px;
  border-left: 1px solid var(--wd-line);
}

.wd-text {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compact square tools */
.wd-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  font: inherit;
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--wd-radius);
  cursor: pointer;
}

.wd-more {
  font-size: 12px;
}

/* The Window Bank */
.wd-bank {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.wd-bank__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--color-text-primary);
  background: rgba(var(--surface-card-rgb), 0.9);
  border: 1px solid var(--wd-line);
  border-radius: var(--wd-radius);
  cursor: pointer;
  transition:
    background var(--wd-dur) ease,
    border-color var(--wd-dur) ease;
}

.wd-bank__btn:hover {
  background: var(--wd-hover);
}

.wd-bank__btn[aria-current="true"] {
  border-color: var(--color-border-active);
  background: var(--wd-wash);
}

.wd-bank__btn[data-place="hidden"],
.wd-bank__btn[data-place="minimized"] {
  border-style: dashed;
  color: var(--color-text-muted);
  background: transparent;
}

.wd-bank__btn[data-place="parked"] {
  border-style: dotted;
  color: var(--color-text-muted);
  background: transparent;
}

.wd-bank__bar {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 2px;
  height: 2px;
  border-radius: 1px;
  background: transparent;
}

.wd-bank__btn[data-tone="needs-you"] .wd-bank__bar {
  background: var(--color-warning);
}

.wd-bank__btn[data-tone="blocked"] .wd-bank__bar {
  background: var(--color-error);
}

.wd-bank__btn[data-tone="finished"] .wd-bank__bar {
  background: var(--color-success);
}

.wd-bank__btn[data-tone="working"] .wd-bank__bar {
  background: rgba(var(--accent-rgb), 0.7);
}

/* Panels rising above the Dock: Arrange, All windows, the switcher's sheet */
.wd-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 336px;
  max-height: 560px;
  padding: 10px;
  overflow: auto;
  background: var(--color-surface-abyss);
  border: 1px solid var(--wd-line);
  border-radius: var(--wd-radius);
  box-sizing: border-box;
}

.wd-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.wd-panel__title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.wd-arrange__state {
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wd-arrange__modes {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.wd-arrange__mode {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--wd-line);
  border-radius: var(--wd-radius);
  cursor: pointer;
}

.wd-arrange__mode:hover {
  background: var(--wd-hover);
}

.wd-arrange__mode[aria-checked="true"] {
  border-color: var(--color-border-active);
  background: var(--wd-wash);
}

.wd-arrange__glyph rect {
  fill: rgba(var(--accent-rgb), 0.16);
  stroke: rgba(var(--accent-rgb), 0.55);
  stroke-width: 0.6;
}

.wd-arrange__glyph rect.is-lead {
  fill: rgba(var(--accent-rgb), 0.42);
}

.wd-arrange__caption {
  min-height: 32px;
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 12px;
  white-space: normal;
}

.wd-arrange__step,
.wd-arrange__foot {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.wd-arrange__row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wd-arrange__rowLabel {
  color: var(--color-text-muted);
  font-size: 12px;
}

.wd-arrange__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.wd-arrange__choice {
  height: 26px;
  padding: 0 8px;
  font: inherit;
  font-size: 12px;
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid var(--wd-line);
  border-radius: var(--wd-radius);
  cursor: pointer;
}

.wd-arrange__choice[aria-checked="true"] {
  color: var(--color-text-primary);
  border-color: var(--color-border-active);
  background: var(--wd-wash);
}

/* Lists: All windows and the switcher's sheet */
.wd-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.wd-list__row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.wd-list__item {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 36px;
  padding: 0 8px;
  font: inherit;
  color: var(--color-text-primary);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--wd-radius);
  cursor: pointer;
}

.wd-list__item:hover,
.wd-list__item[aria-current="true"] {
  background: var(--wd-hover);
}

.wd-list__item[aria-current="true"] {
  border-color: var(--wd-line-strong);
}

.wd-list__glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  color: var(--color-text-secondary);
}

.wd-list__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wd-list__state {
  color: var(--color-text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.wd-list__state[data-tone="needs-you"] {
  color: var(--color-warning);
}

.wd-list__state[data-tone="blocked"] {
  color: var(--color-error);
}

.wd-list__state[data-tone="finished"] {
  color: var(--color-success);
}

.wd-list__hide {
  height: 30px;
  padding: 0 8px;
  font: inherit;
  font-size: 12px;
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid var(--wd-line);
  border-radius: var(--wd-radius);
  cursor: pointer;
}

/* The Work Switcher (narrow displays): controls at least 44px tall */
.wd-switcher {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wd-switch {
  min-height: 52px;
  width: 340px;
}

.wd-switch__step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid var(--wd-line);
  border-radius: var(--wd-radius);
  cursor: pointer;
}

.wd-switch__step:disabled {
  opacity: 0.4;
  cursor: default;
}

.wd-switch__now {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 44px;
  padding: 0 8px;
  font: inherit;
  color: var(--color-text-primary);
  text-align: left;
  background: transparent;
  border: 1px solid var(--wd-line);
  border-radius: var(--wd-radius);
  cursor: pointer;
}

.wd-switch__glyph {
  display: inline-flex;
  width: 22px;
  justify-content: center;
}

.wd-switch__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.wd-switch__title,
.wd-switch__meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wd-switch__meta {
  color: var(--color-text-muted);
  font-size: 12px;
}

.wd-switch__meta [data-tone="needs-you"] {
  color: var(--color-warning);
}

.wd-sheet {
  width: 340px;
}

.wd-sheet__sub {
  margin: 0;
  color: var(--color-warning);
  font-size: 12px;
  font-weight: 600;
}

.wd-sheet__needs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wd-sheet__need {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.wd-sheet__foot {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wd-sheet__foot .wd-btn {
  height: 44px;
}

/* Visible keyboard focus everywhere */
.wd-root button:focus-visible {
  outline: 2px solid var(--color-border-active);
  outline-offset: 1px;
}

.wd-root button:disabled {
  cursor: default;
}

/* Reduced motion (system or the app's own setting): no motion, same controls. */
@media (prefers-reduced-motion: reduce) {
  .wd-root *,
  .wd-root *::before,
  .wd-root *::after {
    animation: none !important;
    transition: none !important;
  }
}

html.reduce-motion .wd-root *,
html.reduce-motion .wd-root *::before,
html.reduce-motion .wd-root *::after {
  animation: none !important;
  transition: none !important;
}

/* Reduced transparency: every surface fully opaque. */
@media (prefers-reduced-transparency: reduce) {
  .wd-root {
    --wd-hover: var(--color-surface-elevated);
    --wd-wash: var(--color-surface-card);
  }
}

/* Forced colors: real boundaries and states stay perceivable. */
@media (forced-colors: active) {
  .wd-dock,
  .wd-panel,
  .wd-bank__btn,
  .wd-tool,
  .wd-return,
  .wd-back,
  .wd-btn,
  .wd-group,
  .wd-arrange__mode,
  .wd-arrange__choice,
  .wd-switch__now,
  .wd-switch__step {
    border: 1px solid CanvasText;
  }
  .wd-bank__btn[aria-current="true"],
  .wd-arrange__mode[aria-checked="true"],
  .wd-arrange__choice[aria-checked="true"] {
    outline: 2px solid Highlight;
  }
  .wd-bank__bar {
    background: CanvasText !important;
  }
  .wd-bank__btn[data-tone="ready"] .wd-bank__bar {
    background: transparent !important;
  }
}
