.tree-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.tree-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex: 0 0 auto;
}
.tree-toolbar .spacer {
  flex: 1;
}
.tree-filter-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.tree-filter-wrap select {
  width: auto;
  padding: 4px 6px;
}

.tree-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px 8px 48px;
}

.tree-none {
  padding: 28px;
  text-align: center;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  min-height: 26px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  position: relative;
}
.tree-row:hover {
  background: var(--bg-sunken);
}
.tree-row.is-done .tree-title {
  color: var(--text-dim);
  text-decoration: line-through;
  text-decoration-color: var(--text-faint);
}
.tree-row.is-context-dim {
  opacity: 0.5;
}
.tree-row.is-context-dim .tree-title {
  font-weight: 400;
  color: var(--text-dim);
}
.tree-row:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}
.tree-row.dragging {
  opacity: 0.4;
}

.tree-chevron {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.tree-chevron:hover {
  color: var(--text);
}
.tree-chevron-empty {
  pointer-events: none;
}

.tree-handle {
  flex: 0 0 auto;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: -1px;
  cursor: grab;
  user-select: none;
  opacity: 0;
}
.tree-row:hover .tree-handle {
  opacity: 1;
}
.tree-handle:active {
  cursor: grabbing;
}

.tree-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.tree-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 340px;
  cursor: pointer;
}
.tree-title:hover {
  color: var(--accent);
}

.tree-progress {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.tree-progress .progress {
  width: 56px;
}
.tree-pct {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
  min-width: 30px;
  font-variant-numeric: tabular-nums;
}

.tree-span,
.tree-cost {
  white-space: nowrap;
}

.tree-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  opacity: 0;
}
.tree-row:hover .tree-actions,
.tree-row:focus-within .tree-actions {
  opacity: 1;
}

.tree-children {
  margin-left: 15px;
  padding-left: 4px;
  border-left: 1px solid var(--border);
}

.tree-row.drop-before::before,
.tree-row.drop-after::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  height: 1px;
  background: var(--accent);
  z-index: 2;
}
.tree-row.drop-before::before {
  top: -1px;
}
.tree-row.drop-after::after {
  bottom: -1px;
}
.tree-row.drop-into {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.tree-row.drop-invalid {
  border-color: var(--bad);
}

.tree-root-drop {
  display: none;
  margin: 8px 0 0;
  padding: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}
.tree-view.dragging .tree-root-drop {
  display: block;
}
.tree-root-drop.active {
  border-color: var(--accent);
  color: var(--accent);
}

.tree-empty-actions {
  display: flex;
  gap: 8px;
}
