.sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.header {
  position: relative;
  padding: 14px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

[data-platform="mac"] .header {
  padding-top: 38px;
}

.title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

.headerActions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dashboardBtn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.dashboardBtn:hover {
  background: var(--hover-bg);
  color: var(--text-muted);
}

.filterToggle {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.filterToggle:hover {
  background: var(--hover-bg);
  color: var(--text-muted);
}

.filterMenu {
  position: absolute;
  top: 100%;
  left: 8px;
  right: 8px;
  margin-top: 4px;
  background: var(--chat-input-bg);
  border: 1px solid var(--divider);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  z-index: 100;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.filterRow {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-primary);
}

.filterLabel {
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 70px;
}

.filterSelect {
  flex: 1;
  min-width: 0;
  background-color: var(--input-bg, var(--hover-bg));
  color: var(--text-primary);
  border: 1px solid var(--divider);
  border-radius: 4px;
  padding: 4px 22px 4px 8px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
  background-position:
    calc(100% - 10px) 50%,
    calc(100% - 6px) 50%;
}

.filterSelect:hover,
.filterSelect:focus {
  border-color: var(--accent-primary);
}

.filterCheckboxRow {
  gap: 8px;
  cursor: pointer;
}

.filterCheckboxRow input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent-primary);
  margin: 0;
}

.filterCheckboxRow .filterLabel {
  min-width: 0;
}

.statusGroupCount {
  margin-left: 6px;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
}

.list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.repoGroup {
  margin-bottom: 4px;
  touch-action: none;
  transition: opacity 0.15s ease;
}

.statusGroup {
  margin-bottom: 4px;
}

.statusGroupHeader {
  position: relative;
  display: flex;
  align-items: center;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  gap: 6px;
  transition: background var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
}

.statusGroupHeader:hover {
  background: var(--hover-bg);
}

.repoGroup.dragging {
  opacity: 0.35;
  cursor: grabbing;
  user-select: none;
}

.repoGroup.dropTarget {
  /* subtle highlight on the target area */
}

.dropIndicator {
  height: 2px;
  background: var(--accent-primary);
  border-radius: 1px;
  margin: 2px 8px;
  box-shadow: 0 0 4px rgba(var(--accent-primary-rgb), 0.4);
}

.repoHeader {
  position: relative;
  display: flex;
  align-items: center;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: grab;
  gap: 6px;
  transition: background var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
}

.dragging .repoHeader {
  cursor: grabbing;
}

.repoHeader:hover {
  background: var(--hover-bg);
}

/* Highlight when the project-scoped view is active for this repo. The
   selectedBg color matches the workspace-row selection so both selection
   types read as the same affordance. */
.repoHeaderSelected,
.repoHeaderSelected:hover {
  background: var(--selected-bg);
}

.chevron {
  font-size: 10px;
  color: var(--text-dim);
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  /* Reset button defaults — chevron renders as a focusable affordance
     so the collapse toggle is keyboard-accessible, but it must look
     identical to the prior span so the sidebar visual cadence holds. */
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast);
}

.chevron:hover {
  background: var(--hover-bg);
  border-color: var(--divider);
  color: var(--text-primary);
}

.chevron:focus-visible {
  outline: none;
  border-color: var(--accent-primary);
}

.repoName {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.repoTitle {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.iconBtn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
  display: flex;
  align-items: center;
  border-radius: 4px;
  flex-shrink: 0;
}

.repoHeader:hover .iconBtn,
.repoHeader:focus-within .iconBtn,
.wsItem:hover .iconBtn {
  opacity: 1;
}

/* Hide action buttons when shortcut badges are visible to prevent overlap.
   Applies to both project headers (repo-mode badge) and workspace rows
   (status-mode badge — the badge anchors to .wsItem:right via .wsActions). */
.repoHeader:has(.shortcutBadgeVisible) .iconBtn,
.wsItem:has(.shortcutBadgeVisible) .iconBtn {
  opacity: 0;
  pointer-events: none;
}

.iconBtn:hover {
  color: var(--accent-primary);
  background: var(--accent-bg);
}

.iconBtnDanger {
  color: var(--status-stopped);
}

.iconBtnDanger:hover {
  color: var(--accent-error);
  background: var(--accent-error-hover);
}

.invalidBadge {
  color: var(--status-stopped);
  font-weight: bold;
  font-size: var(--body-size);
}

.repoIcon {
  margin-right: 2px;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

/* Running count badge next to repo name */
.runningBadge {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-primary);
  background: var(--accent-bg);
  padding: 0 5px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

/* Keyboard shortcut badge shown on Cmd/Ctrl hold — absolutely positioned
   so it doesn't reflow the header when it appears/disappears. */
.shortcutBadge {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-family: inherit;
  color: var(--accent-primary);
  background: var(--accent-bg-strong);
  border: 1px solid rgba(var(--accent-primary-rgb), 0.25);
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0s;
}

.shortcutBadgeVisible {
  opacity: 1;
  transition: opacity 0.5s ease;
}

/* Workspace items */
.wsItem {
  display: flex;
  align-items: center;
  padding: 6px 8px 6px 28px;
  border-radius: 6px;
  cursor: pointer;
  gap: 8px;
  position: relative;
  transition: background var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
}

.wsItem:hover {
  background: var(--hover-bg);
}

.wsSelected {
  background: var(--selected-bg);
}

.wsSelected::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 1px;
  background: var(--accent-primary);
}

/* Workspace drag-reorder visuals. Mirrors the repo-group reorder + the
 * terminal/workspace tab reorder: a translucent dragged item, an accent
 * bar drawn at the top/bottom edge of the hover target showing where the
 * dropped workspace will land. Pseudo-elements are safe here — wsItem only
 * uses ::before for the selection bar (left edge), so top/bottom indicators
 * don't conflict. */
.wsDragging {
  opacity: 0.4;
  cursor: grabbing;
}

.wsItem[data-drop-before="true"]::after,
.wsItem[data-drop-after="true"]::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--accent-primary);
  border-radius: 1px;
  pointer-events: none;
}

.wsItem[data-drop-before="true"]::after {
  top: -1px;
}

.wsItem[data-drop-after="true"]::after {
  bottom: -1px;
}

.wsItemLoading {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
}

.statusDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin: 0 4px;
}

.statusSpinner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: var(--accent-primary);
  flex-shrink: 0;
  filter: drop-shadow(0 0 3px rgba(var(--accent-primary-rgb), 0.4));
}

.statusSpinnerRing {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: conic-gradient(currentColor 225deg, transparent 225deg);
  mask: radial-gradient(circle closest-side, transparent calc(100% - 2px), black calc(100% - 2px));
  -webkit-mask: radial-gradient(circle closest-side, transparent calc(100% - 2px), black calc(100% - 2px));
  animation: spin 0.8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .statusSpinnerRing {
    animation: none;
  }
}

.statusIcon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  flex-shrink: 0;
}

.wsActions {
  display: flex;
  align-items: center;
  margin-left: auto;
  gap: 2px;
}

/* Issue/PR -> workspace link indicator (issue #898). Sits between the
   workspace info column and the hover action buttons; accent-tinted so
   it reads as "this workspace has an upstream item" at a glance. */
.wsScmLink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  flex-shrink: 0;
  color: var(--accent-primary);
}

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

.wsName {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wsNameInput {
  font-size: 13px;
  font-family: inherit;
  background: var(--chat-input-bg);
  color: var(--text-primary);
  border: 1px solid var(--accent-primary);
  border-radius: 4px;
  padding: 0 4px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.badgeDone,
.badgePlan,
.badgeAsk {
  width: 14px;
  flex-shrink: 0;
  display: inline-flex;
  justify-content: center;
  animation: pulse-badge 2s ease-in-out infinite;
}

.badgeDone {
  color: var(--badge-done);
}

.badgePlan {
  color: var(--badge-plan);
}

.badgeAsk {
  color: var(--badge-ask);
}

@keyframes pulse-badge {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

@media (prefers-reduced-motion: reduce) {
  .badgeDone,
  .badgePlan,
  .badgeAsk {
    animation: none;
  }
}

.wsUnread .wsName {
  font-weight: 700;
}

.wsBranch {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}

/* Running-commands summary row. Collapsed by default — clicking expands the
   list of individual commands underneath. Indented to nest visually under
   the workspace branch line. */
.terminalCommandSummary {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  margin-top: 2px;
  margin-left: 14px;
  cursor: pointer;
  text-align: left;
}

.terminalCommandSummary:hover .commandText {
  color: var(--text);
}

.commandChevron {
  opacity: 0.6;
  flex-shrink: 0;
}

/* Individual command rows shown when the summary is expanded. Indented
   slightly more than the summary so the hierarchy reads correctly. */
.terminalCommandItem {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
  margin-left: 32px;
}

.terminalCommandItem .commandText {
  flex: 1;
  min-width: 0;
}

/* Stop button to interrupt the foreground command on a PTY (sends SIGINT
   to the foreground process group on Unix, writes \x03 on Windows). Hidden
   until the row is hovered to keep the dense list visually quiet. */
.commandStopBtn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 1px;
  margin: 0;
  color: var(--text-dim);
  cursor: pointer;
  opacity: 0;
  border-radius: 2px;
  line-height: 1;
}

.terminalCommandItem:hover .commandStopBtn,
.commandStopBtn:focus-visible {
  opacity: 1;
}

.commandStopBtn:hover {
  color: var(--status-stopped);
  background: var(--hover-bg);
}

.runningIcon {
  color: var(--status-running);
  animation: spin 2s linear infinite;
  flex-shrink: 0;
  display: block;
}

/* Wrapper for the Cog icon — without this, the inline span's baseline
   centers the SVG to the text baseline rather than its midline, so the
   gear floats above the command text. */
.iconWrap {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 1;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.successIcon {
  color: var(--status-running);
  flex-shrink: 0;
}

.errorIcon {
  color: var(--status-stopped);
  flex-shrink: 0;
}

.commandIcon {
  opacity: 0.7;
  flex-shrink: 0;
}

.commandText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.emptyState {
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.emptyStateMessage {
  font-size: var(--body-size);
  line-height: 1.4;
  color: var(--text-muted);
}

.emptyStateActions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.emptyStateAction {
  background: var(--hover-bg);
  border: 1px solid var(--divider);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: var(--body-size);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.emptyStateAction:hover {
  color: var(--accent-primary);
  background: var(--accent-bg);
  border-color: rgba(var(--accent-primary-rgb), 0.25);
}

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
}

.footerBtn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.footerBtn:hover {
  color: var(--accent-primary);
  background: var(--accent-bg);
}

/* Remote / shared sections */

.remoteSection {
  border-top: 1px solid var(--divider);
}

.remoteHeader {
  opacity: 0.7;
  cursor: default;
}

.remoteConnectionHeader {
  opacity: 0.8;
}

.sectionLabel {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.smallBtn {
  font-size: var(--fs-xs);
}

.smallBtnDim {
  font-size: var(--fs-xs);
  opacity: 0.5;
}

.smallBtnConnecting {
  font-size: var(--fs-xs);
  opacity: 0.5;
}

.remoteStatusDot {
  margin-right: var(--space-1);
}

.remoteStatusIdle {
  background: var(--status-idle);
}

.remoteStatusActive {
  background: var(--status-running);
}

.remoteStatusStopped {
  background: var(--status-stopped);
}

.remoteRepoHeader {
  padding-left: var(--space-3);
}

.remotePlaceholder {
  opacity: 0.5;
}

.wsNamePlaceholder {
  opacity: 0.5;
}

.connectError {
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-xs);
  color: var(--status-stopped);
  line-height: 1.3;
}

.shareBtnActive {
  color: var(--status-running);
}
