/* Desktop shell: top bar, taskbar, toasts, notification center, command palette. */

.desktop {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: var(--shell-top-h) 1fr var(--shell-dock-h);
  background: var(--surface-0);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.desktop.is-ready {
  opacity: 1;
}
body.is-dragging {
  cursor: grabbing;
  user-select: none;
}
body.is-dragging iframe,
body.is-dragging .xterm {
  pointer-events: none;
}

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: relative;
  z-index: 5000;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-3) 0 var(--sp-4);
  background: var(--surface-0);
  user-select: none;
}
.tb-left,
.tb-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.tb-left {
  flex: 1 1 0;
  min-width: 0;
}
.tb-mid {
  flex: 0 1 440px;
  min-width: 0;
}
.tb-right {
  flex: 1 0 auto;
  justify-content: flex-end;
  gap: var(--sp-1);
}
.tb-sep {
  width: 1px;
  height: 16px;
  background: var(--rule-2);
  margin: 0 var(--sp-1);
}
.ws {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  color: var(--ink-3);
  font-size: var(--fs-meta);
}
.ws .ico {
  color: var(--ink-4);
}
.search {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 28px;
  width: 100%;
  padding: 0 var(--sp-1h) 0 var(--sp-3);
  border: 0;
  border-radius: var(--radius-control);
  background: var(--surface-1);
  box-shadow: inset 0 0 0 1px var(--rule-1);
  color: var(--ink-3);
  font-size: 13px;
  cursor: pointer;
  transition: box-shadow var(--dur-1), color var(--dur-1);
}
.search span {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search:hover {
  box-shadow: inset 0 0 0 1px var(--rule-3);
  color: var(--ink-2);
}

/* Status chips: quiet text, shown only when they matter. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1h);
  height: 28px;
  padding: 0 var(--sp-2);
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  cursor: pointer;
  font: var(--fs-meta) var(--sans);
  white-space: nowrap;
}
.chip:hover {
  background: var(--surface-1);
}
.chip-k {
  color: var(--ink-3);
}
.chip-v {
  color: var(--ink-2);
}
.chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-4);
}
.chip[data-state="ok"] .chip-dot {
  background: var(--fine);
}
.chip[data-state="warn"] .chip-dot {
  background: var(--caution);
}
.chip[data-state="err"] .chip-dot {
  background: var(--danger);
}
.chip[data-state="err"] .chip-v {
  color: var(--danger-ink);
}
.chip[data-state="busy"] .chip-dot {
  background: var(--info);
  animation: pulse 1.2s infinite;
}
.chip[data-state="off"] .chip-v {
  color: var(--ink-3);
}

.bell {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}
.bell:hover {
  color: var(--ink-1);
  background: var(--surface-1);
}
.bell-count {
  position: absolute;
  top: 1px;
  right: 0;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--ink-on-accent);
  font: var(--fw-strong) 10px/15px var(--sans);
  text-align: center;
}
.clock {
  min-width: 44px;
  padding-left: var(--sp-1);
  color: var(--ink-2);
  font-size: var(--fs-meta);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- taskbar */
.taskbar {
  position: relative;
  z-index: 5000;
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0 var(--sp-3);
  background: var(--surface-0);
  user-select: none;
  min-width: 0;
}
.tk-launchers {
  display: flex;
  gap: 2px;
}
.tk-launch {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  color: var(--ink-2);
  cursor: pointer;
  transition: background var(--dur-1), color var(--dur-1);
}
.tk-launch:hover {
  color: var(--ink-1);
  background: var(--surface-1);
}
.tk-launch.is-open::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--ink-3);
}
.tk-sep {
  width: 1px;
  height: 20px;
  background: var(--rule-2);
  margin: 0 var(--sp-2);
}
.tk-wins {
  display: flex;
  gap: var(--sp-1);
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.tk-win {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  max-width: 220px;
  flex: 0 1 auto;
  height: 34px;
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--dur-1), color var(--dur-1);
}
.tk-win .ico {
  color: var(--ink-3);
}
.tk-win:hover {
  background: var(--surface-1);
  color: var(--ink-1);
}
.tk-win.is-focused {
  background: var(--surface-1);
  color: var(--ink-1);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.tk-win.is-focused .ico {
  color: var(--ink-2);
}
.tk-win.is-min {
  color: var(--ink-3);
}
.tk-win-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tk-right {
  display: flex;
  align-items: center;
  padding-left: var(--sp-2);
}

/* ---------------------------------------------------------------- toasts & notification center */
.toasts {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  right: 10px;
  z-index: 7000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 340px;
  pointer-events: none;
}
.toast,
.nc-item {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 10px 28px 10px 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: rgba(13, 17, 18, 0.97);
  box-shadow: var(--shadow);
  pointer-events: auto;
  overflow: hidden;
  animation: toast-in 0.18s var(--ease);
}
.toast.is-leaving {
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.16s, transform 0.16s;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
}
.n-bar {
  flex: none;
  width: 3px;
  margin-left: -1px;
  background: var(--blue);
}
.lvl-success .n-bar {
  background: var(--acc);
}
.lvl-warn .n-bar {
  background: var(--amber);
}
.lvl-error .n-bar {
  background: var(--red);
}
.n-main {
  min-width: 0;
  flex: 1;
}
.n-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.n-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.n-meta {
  margin-left: auto;
  flex: none;
  color: var(--faint);
  font: 11px var(--sans);
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.n-body {
  margin-top: 2px;
  color: var(--text-2);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 8.5em;
  overflow: hidden;
}
.n-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.toast-x {
  position: absolute;
  top: 8px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--faint);
  cursor: pointer;
}
.toast-x:hover {
  color: var(--text);
  background: var(--panel-3);
}

.nc {
  position: fixed;
  top: calc(var(--topbar-h) + 6px);
  right: 8px;
  bottom: calc(var(--taskbar-h) + 8px);
  z-index: 7100;
  display: flex;
  flex-direction: column;
  width: 370px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: rgba(10, 13, 14, 0.98);
  box-shadow: var(--shadow);
  animation: pop 0.14s var(--ease);
}
.nc-head {
  display: flex;
  align-items: center;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--line);
}
.nc-title {
  font: 600 11px var(--sans);
  color: var(--text-2);
}
.nc-list {
  flex: 1;
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nc-item {
  box-shadow: none;
  padding-right: 10px;
  background: var(--panel);
  border-color: var(--line);
  animation: none;
  flex: none;
}
.nc-empty {
  padding: 30px 16px;
  color: var(--dim);
  text-align: center;
}

/* ---------------------------------------------------------------- palette */
.pal-layer {
  position: fixed;
  inset: 0;
  z-index: 8500;
}
.pal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 5, 0.45);
}
.pal {
  position: absolute;
  top: 12vh;
  left: 50%;
  width: min(600px, calc(100vw - 32px));
  transform: translateX(-50%);
  border: 1px solid var(--line-3);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow), 0 0 0 1px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: pop 0.12s var(--ease);
}
.pal-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
}
.pal-input {
  flex: 1;
  height: 44px;
  border: 0;
  outline: none;
  background: none;
  font-size: 14px;
}
.pal-input::placeholder {
  color: var(--faint);
}
.pal-list {
  max-height: min(420px, 60vh);
  overflow: auto;
  padding: 6px;
}
.pal-group {
  padding: 8px 8px 4px;
  color: var(--faint);
  font: 11px var(--sans);
}
.pal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r);
  color: var(--text-2);
  cursor: pointer;
}
.pal-item .ico {
  color: var(--dim);
}
.pal-item.is-sel {
  background: var(--panel-3);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--acc);
}
.pal-item.is-sel .ico {
  color: var(--acc);
}
.pal-label {
  white-space: nowrap;
}
.pal-hint {
  flex: 1;
  min-width: 0;
  color: var(--faint);
  font: 11px var(--sans);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pal-kind {
  margin-left: auto;
  color: var(--faint);
  font: 11px var(--sans);
}
.pal-empty {
  padding: 18px;
  color: var(--dim);
  text-align: center;
}

@media (max-width: 1180px) {
  .search span {
    display: none;
  }
  .tb-mid {
    flex: 0 0 auto;
  }
  .search {
    width: auto;
  }
  .chip-k {
    display: none;
  }
}
@media (max-width: 900px) {
  .credit-bar {
    font-size: 10px;
  }
  .tk-win {
    max-width: 130px;
  }
}
